261 lines
11 KiB
JSON
261 lines
11 KiB
JSON
|
{
|
||
|
"router": {
|
||
|
"middlewares": [
|
||
|
{
|
||
|
"pkg": "github.com/go-chi/chi/middleware",
|
||
|
"func": "RequestID",
|
||
|
"comment": "RequestID is a middleware that injects a request ID into the context of each\nrequest. A request ID is a string of the form \"host.example.com/random-0001\",\nwhere \"random\" is a base62 random string that uniquely identifies this go\nprocess, and where the last number is an atomically incremented request\ncounter.\n",
|
||
|
"file": "github.com/go-chi/chi/middleware/request_id.go",
|
||
|
"line": 63
|
||
|
},
|
||
|
{
|
||
|
"pkg": "github.com/go-chi/chi/middleware",
|
||
|
"func": "Logger",
|
||
|
"comment": "Logger is a middleware that logs the start and end of each request, along\nwith some useful data about what was requested, what the response status was,\nand how long it took to return. When standard output is a TTY, Logger will\nprint in color, otherwise it will print in black and white. Logger prints a\nrequest ID if one is provided.\n\nAlternatively, look at https://github.com/pressly/lg and the `lg.RequestLogger`\nmiddleware pkg.\n",
|
||
|
"file": "github.com/go-chi/chi/middleware/logger.go",
|
||
|
"line": 26
|
||
|
},
|
||
|
{
|
||
|
"pkg": "github.com/go-chi/chi/middleware",
|
||
|
"func": "Recoverer",
|
||
|
"comment": "Recoverer is a middleware that recovers from panics, logs the panic (and a\nbacktrace), and returns a HTTP 500 (Internal Server Error) status if\npossible. Recoverer prints a request ID if one is provided.\n\nAlternatively, look at https://github.com/pressly/lg middleware pkgs.\n",
|
||
|
"file": "github.com/go-chi/chi/middleware/recoverer.go",
|
||
|
"line": 18
|
||
|
},
|
||
|
{
|
||
|
"pkg": "github.com/go-chi/chi/middleware",
|
||
|
"func": "URLFormat",
|
||
|
"comment": "URLFormat is a middleware that parses the url extension from a request path and stores it\non the context as a string under the key `middleware.URLFormatCtxKey`. The middleware will\ntrim the suffix from the routing path and continue routing.\n\nRouters should not include a url parameter for the suffix when using this middleware.\n\nSample usage.. for url paths: `/articles/1`, `/articles/1.json` and `/articles/1.xml`\n\n func routes() http.Handler {\n r := chi.NewRouter()\n r.Use(middleware.URLFormat)\n\n r.Get(\"/articles/{id}\", ListArticles)\n\n return r\n }\n\n func ListArticles(w http.ResponseWriter, r *http.Request) {\n\t urlFormat, _ := r.Context().Value(middleware.URLFormatCtxKey).(string)\n\n\t switch urlFormat {\n\t case \"json\":\n\t \trender.JSON(w, r, articles)\n\t case \"xml:\"\n\t \trender.XML(w, r, articles)\n\t default:\n\t \trender.JSON(w, r, articles)\n\t }\n}\n",
|
||
|
"file": "github.com/go-chi/chi/middleware/url_format.go",
|
||
|
"line": 45
|
||
|
},
|
||
|
{
|
||
|
"pkg": "github.com/go-chi/render",
|
||
|
"func": "SetContentType.func1",
|
||
|
"comment": "",
|
||
|
"file": "github.com/go-chi/render/content_type.go",
|
||
|
"line": 49,
|
||
|
"anonymous": true
|
||
|
}
|
||
|
],
|
||
|
"routes": {
|
||
|
"/": {
|
||
|
"handlers": {
|
||
|
"GET": {
|
||
|
"middlewares": [],
|
||
|
"method": "GET",
|
||
|
"pkg": "",
|
||
|
"func": "main.main.func1",
|
||
|
"comment": "",
|
||
|
"file": "github.com/go-chi/chi/_examples/rest/main.go",
|
||
|
"line": 69,
|
||
|
"anonymous": true
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"/admin/*": {
|
||
|
"router": {
|
||
|
"middlewares": [
|
||
|
{
|
||
|
"pkg": "",
|
||
|
"func": "main.AdminOnly",
|
||
|
"comment": "AdminOnly middleware restricts access to just administrators.\n",
|
||
|
"file": "github.com/go-chi/chi/_examples/rest/main.go",
|
||
|
"line": 238
|
||
|
}
|
||
|
],
|
||
|
"routes": {
|
||
|
"/": {
|
||
|
"handlers": {
|
||
|
"GET": {
|
||
|
"middlewares": [],
|
||
|
"method": "GET",
|
||
|
"pkg": "",
|
||
|
"func": "main.adminRouter.func1",
|
||
|
"comment": "",
|
||
|
"file": "github.com/go-chi/chi/_examples/rest/main.go",
|
||
|
"line": 225,
|
||
|
"anonymous": true
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"/accounts": {
|
||
|
"handlers": {
|
||
|
"GET": {
|
||
|
"middlewares": [],
|
||
|
"method": "GET",
|
||
|
"pkg": "",
|
||
|
"func": "main.adminRouter.func2",
|
||
|
"comment": "",
|
||
|
"file": "github.com/go-chi/chi/_examples/rest/main.go",
|
||
|
"line": 228,
|
||
|
"anonymous": true
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"/users/{userId}": {
|
||
|
"handlers": {
|
||
|
"GET": {
|
||
|
"middlewares": [],
|
||
|
"method": "GET",
|
||
|
"pkg": "",
|
||
|
"func": "main.adminRouter.func3",
|
||
|
"comment": "",
|
||
|
"file": "github.com/go-chi/chi/_examples/rest/main.go",
|
||
|
"line": 231,
|
||
|
"anonymous": true
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"/articles/*": {
|
||
|
"router": {
|
||
|
"middlewares": [],
|
||
|
"routes": {
|
||
|
"/": {
|
||
|
"handlers": {
|
||
|
"GET": {
|
||
|
"middlewares": [
|
||
|
{
|
||
|
"pkg": "",
|
||
|
"func": "main.paginate",
|
||
|
"comment": "paginate is a stub, but very possible to implement middleware logic\nto handle the request params for handling a paginated request.\n",
|
||
|
"file": "github.com/go-chi/chi/_examples/rest/main.go",
|
||
|
"line": 251
|
||
|
}
|
||
|
],
|
||
|
"method": "GET",
|
||
|
"pkg": "",
|
||
|
"func": "main.ListArticles",
|
||
|
"comment": "",
|
||
|
"file": "github.com/go-chi/chi/_examples/rest/main.go",
|
||
|
"line": 117
|
||
|
},
|
||
|
"POST": {
|
||
|
"middlewares": [],
|
||
|
"method": "POST",
|
||
|
"pkg": "",
|
||
|
"func": "main.CreateArticle",
|
||
|
"comment": "CreateArticle persists the posted Article and returns it\nback to the client as an acknowledgement.\n",
|
||
|
"file": "github.com/go-chi/chi/_examples/rest/main.go",
|
||
|
"line": 158
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"/search": {
|
||
|
"handlers": {
|
||
|
"GET": {
|
||
|
"middlewares": [],
|
||
|
"method": "GET",
|
||
|
"pkg": "",
|
||
|
"func": "main.SearchArticles",
|
||
|
"comment": "SearchArticles searches the Articles data for a matching article.\nIt's just a stub, but you get the idea.\n",
|
||
|
"file": "github.com/go-chi/chi/_examples/rest/main.go",
|
||
|
"line": 152
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"/{articleID}/*": {
|
||
|
"router": {
|
||
|
"middlewares": [
|
||
|
{
|
||
|
"pkg": "",
|
||
|
"func": "main.ArticleCtx",
|
||
|
"comment": "ArticleCtx middleware is used to load an Article object from\nthe URL parameters passed through as the request. In case\nthe Article could not be found, we stop here and return a 404.\n",
|
||
|
"file": "github.com/go-chi/chi/_examples/rest/main.go",
|
||
|
"line": 127
|
||
|
}
|
||
|
],
|
||
|
"routes": {
|
||
|
"/": {
|
||
|
"handlers": {
|
||
|
"DELETE": {
|
||
|
"middlewares": [],
|
||
|
"method": "DELETE",
|
||
|
"pkg": "",
|
||
|
"func": "main.DeleteArticle",
|
||
|
"comment": "DeleteArticle removes an existing Article from our persistent store.\n",
|
||
|
"file": "github.com/go-chi/chi/_examples/rest/main.go",
|
||
|
"line": 204
|
||
|
},
|
||
|
"GET": {
|
||
|
"middlewares": [],
|
||
|
"method": "GET",
|
||
|
"pkg": "",
|
||
|
"func": "main.GetArticle",
|
||
|
"comment": "GetArticle returns the specific Article. You'll notice it just\nfetches the Article right off the context, as its understood that\nif we made it this far, the Article must be on the context. In case\nits not due to a bug, then it will panic, and our Recoverer will save us.\n",
|
||
|
"file": "github.com/go-chi/chi/_examples/rest/main.go",
|
||
|
"line": 176
|
||
|
},
|
||
|
"PUT": {
|
||
|
"middlewares": [],
|
||
|
"method": "PUT",
|
||
|
"pkg": "",
|
||
|
"func": "main.UpdateArticle",
|
||
|
"comment": "UpdateArticle updates an existing Article in our persistent store.\n",
|
||
|
"file": "github.com/go-chi/chi/_examples/rest/main.go",
|
||
|
"line": 189
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"/{articleSlug:[a-z-]+}": {
|
||
|
"handlers": {
|
||
|
"GET": {
|
||
|
"middlewares": [
|
||
|
{
|
||
|
"pkg": "",
|
||
|
"func": "main.ArticleCtx",
|
||
|
"comment": "ArticleCtx middleware is used to load an Article object from\nthe URL parameters passed through as the request. In case\nthe Article could not be found, we stop here and return a 404.\n",
|
||
|
"file": "github.com/go-chi/chi/_examples/rest/main.go",
|
||
|
"line": 127
|
||
|
}
|
||
|
],
|
||
|
"method": "GET",
|
||
|
"pkg": "",
|
||
|
"func": "main.GetArticle",
|
||
|
"comment": "GetArticle returns the specific Article. You'll notice it just\nfetches the Article right off the context, as its understood that\nif we made it this far, the Article must be on the context. In case\nits not due to a bug, then it will panic, and our Recoverer will save us.\n",
|
||
|
"file": "github.com/go-chi/chi/_examples/rest/main.go",
|
||
|
"line": 176
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"/panic": {
|
||
|
"handlers": {
|
||
|
"GET": {
|
||
|
"middlewares": [],
|
||
|
"method": "GET",
|
||
|
"pkg": "",
|
||
|
"func": "main.main.func3",
|
||
|
"comment": "",
|
||
|
"file": "github.com/go-chi/chi/_examples/rest/main.go",
|
||
|
"line": 77,
|
||
|
"anonymous": true
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"/ping": {
|
||
|
"handlers": {
|
||
|
"GET": {
|
||
|
"middlewares": [],
|
||
|
"method": "GET",
|
||
|
"pkg": "",
|
||
|
"func": "main.main.func2",
|
||
|
"comment": "",
|
||
|
"file": "github.com/go-chi/chi/_examples/rest/main.go",
|
||
|
"line": 73,
|
||
|
"anonymous": true
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|