File: routes.json

package info (click to toggle)
golang-github-go-chi-chi 5.0.7-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, experimental, sid, trixie
  • size: 600 kB
  • sloc: makefile: 15
file content (260 lines) | stat: -rw-r--r-- 11,317 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
{
  "router": {
    "middlewares": [
      {
        "pkg": "github.com/go-chi/chi/v5/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/v5/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/v5/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/v5/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
          }
        }
      }
    }
  }
}