summaryrefslogtreecommitdiff
path: root/vendor/github.com/go-openapi/runtime/middleware/denco/README.md
diff options
context:
space:
mode:
authorLibravatar Vyr Cossont <VyrCossont@users.noreply.github.com>2024-03-06 09:05:45 -0800
committerLibravatar GitHub <noreply@github.com>2024-03-06 18:05:45 +0100
commitfc3741365c27f1d703e8a736af95b95ff811cc45 (patch)
tree929f1d5e20d1469d63a3dfe81d38d89f9a073c5a /vendor/github.com/go-openapi/runtime/middleware/denco/README.md
parent[chore/bugfix] Little DB fixes (#2726) (diff)
downloadgotosocial-fc3741365c27f1d703e8a736af95b95ff811cc45.tar.xz
[bugfix] Fix Swagger spec and add test script (#2698)
* Add Swagger spec test script * Fix Swagger spec errors not related to statuses with polls * Add API tests that post a status with a poll * Fix creating a status with a poll from form params * Fix Swagger spec errors related to statuses with polls (this is the last error) * Fix Swagger spec warnings not related to unused definitions * Suppress a duplicate list update params definition that was somehow causing wrong param names * Add Swagger test to CI - updates Drone config - vendorizes go-swagger - fixes a file extension issue that caused the test script to generate JSON instead of YAML with the vendorized version * Put `Sample: ` on its own line everywhere * Remove unused id param from emojiCategoriesGet * Add 5 more pairs of profile fields to account update API Swagger * Remove Swagger prefix from dummy fields It makes the generated code look weird * Manually annotate params for statusCreate operation * Fix all remaining Swagger spec warnings - Change some models into operation parameters - Ignore models that already correspond to manually documented operation parameters but can't be trivially changed (those with file fields) * Documented that creating a status with scheduled_at isn't implemented yet * sign drone.yml * Fix filter API Swagger errors * fixup! Fix filter API Swagger errors --------- Co-authored-by: tobi <tobi.smethurst@protonmail.com>
Diffstat (limited to 'vendor/github.com/go-openapi/runtime/middleware/denco/README.md')
-rw-r--r--vendor/github.com/go-openapi/runtime/middleware/denco/README.md180
1 files changed, 180 insertions, 0 deletions
diff --git a/vendor/github.com/go-openapi/runtime/middleware/denco/README.md b/vendor/github.com/go-openapi/runtime/middleware/denco/README.md
new file mode 100644
index 000000000..30109e17d
--- /dev/null
+++ b/vendor/github.com/go-openapi/runtime/middleware/denco/README.md
@@ -0,0 +1,180 @@
+# Denco [![Build Status](https://travis-ci.org/naoina/denco.png?branch=master)](https://travis-ci.org/naoina/denco)
+
+The fast and flexible HTTP request router for [Go](http://golang.org).
+
+Denco is based on Double-Array implementation of [Kocha-urlrouter](https://github.com/naoina/kocha-urlrouter).
+However, Denco is optimized and some features added.
+
+## Features
+
+* Fast (See [go-http-routing-benchmark](https://github.com/naoina/go-http-routing-benchmark))
+* [URL patterns](#url-patterns) (`/foo/:bar` and `/foo/*wildcard`)
+* Small (but enough) URL router API
+* HTTP request multiplexer like `http.ServeMux`
+
+## Installation
+
+ go get -u github.com/go-openapi/runtime/middleware/denco
+
+## Using as HTTP request multiplexer
+
+```go
+package main
+
+import (
+ "fmt"
+ "log"
+ "net/http"
+
+ "github.com/go-openapi/runtime/middleware/denco"
+)
+
+func Index(w http.ResponseWriter, r *http.Request, params denco.Params) {
+ fmt.Fprintf(w, "Welcome to Denco!\n")
+}
+
+func User(w http.ResponseWriter, r *http.Request, params denco.Params) {
+ fmt.Fprintf(w, "Hello %s!\n", params.Get("name"))
+}
+
+func main() {
+ mux := denco.NewMux()
+ handler, err := mux.Build([]denco.Handler{
+ mux.GET("/", Index),
+ mux.GET("/user/:name", User),
+ mux.POST("/user/:name", User),
+ })
+ if err != nil {
+ panic(err)
+ }
+ log.Fatal(http.ListenAndServe(":8080", handler))
+}
+```
+
+## Using as URL router
+
+```go
+package main
+
+import (
+ "fmt"
+
+ "github.com/go-openapi/runtime/middleware/denco"
+)
+
+type route struct {
+ name string
+}
+
+func main() {
+ router := denco.New()
+ router.Build([]denco.Record{
+ {"/", &route{"root"}},
+ {"/user/:id", &route{"user"}},
+ {"/user/:name/:id", &route{"username"}},
+ {"/static/*filepath", &route{"static"}},
+ })
+
+ data, params, found := router.Lookup("/")
+ // print `&main.route{name:"root"}, denco.Params(nil), true`.
+ fmt.Printf("%#v, %#v, %#v\n", data, params, found)
+
+ data, params, found = router.Lookup("/user/hoge")
+ // print `&main.route{name:"user"}, denco.Params{denco.Param{Name:"id", Value:"hoge"}}, true`.
+ fmt.Printf("%#v, %#v, %#v\n", data, params, found)
+
+ data, params, found = router.Lookup("/user/hoge/7")
+ // print `&main.route{name:"username"}, denco.Params{denco.Param{Name:"name", Value:"hoge"}, denco.Param{Name:"id", Value:"7"}}, true`.
+ fmt.Printf("%#v, %#v, %#v\n", data, params, found)
+
+ data, params, found = router.Lookup("/static/path/to/file")
+ // print `&main.route{name:"static"}, denco.Params{denco.Param{Name:"filepath", Value:"path/to/file"}}, true`.
+ fmt.Printf("%#v, %#v, %#v\n", data, params, found)
+}
+```
+
+See [Godoc](http://godoc.org/github.com/go-openapi/runtime/middleware/denco) for more details.
+
+## Getting the value of path parameter
+
+You can get the value of path parameter by 2 ways.
+
+1. Using [`denco.Params.Get`](http://godoc.org/github.com/go-openapi/runtime/middleware/denco#Params.Get) method
+2. Find by loop
+
+```go
+package main
+
+import (
+ "fmt"
+
+ "github.com/go-openapi/runtime/middleware/denco"
+)
+
+func main() {
+ router := denco.New()
+ if err := router.Build([]denco.Record{
+ {"/user/:name/:id", "route1"},
+ }); err != nil {
+ panic(err)
+ }
+
+ // 1. Using denco.Params.Get method.
+ _, params, _ := router.Lookup("/user/alice/1")
+ name := params.Get("name")
+ if name != "" {
+ fmt.Printf("Hello %s.\n", name) // prints "Hello alice.".
+ }
+
+ // 2. Find by loop.
+ for _, param := range params {
+ if param.Name == "name" {
+ fmt.Printf("Hello %s.\n", name) // prints "Hello alice.".
+ }
+ }
+}
+```
+
+## URL patterns
+
+Denco's route matching strategy is "most nearly matching".
+
+When routes `/:name` and `/alice` have been built, URI `/alice` matches the route `/alice`, not `/:name`.
+Because URI `/alice` is more match with the route `/alice` than `/:name`.
+
+For more example, when routes below have been built:
+
+```
+/user/alice
+/user/:name
+/user/:name/:id
+/user/alice/:id
+/user/:id/bob
+```
+
+Routes matching are:
+
+```
+/user/alice => "/user/alice" (no match with "/user/:name")
+/user/bob => "/user/:name"
+/user/naoina/1 => "/user/:name/1"
+/user/alice/1 => "/user/alice/:id" (no match with "/user/:name/:id")
+/user/1/bob => "/user/:id/bob" (no match with "/user/:name/:id")
+/user/alice/bob => "/user/alice/:id" (no match with "/user/:name/:id" and "/user/:id/bob")
+```
+
+## Limitation
+
+Denco has some limitations below.
+
+* Number of param records (such as `/:name`) must be less than 2^22
+* Number of elements of internal slice must be less than 2^22
+
+## Benchmarks
+
+ cd $GOPATH/github.com/go-openapi/runtime/middleware/denco
+ go test -bench . -benchmem
+
+## License
+
+Denco is licensed under the MIT License.