MCPcopy Create free account
hub / github.com/a-h/rest / Route

Method Route

api.go:189–211  ·  view source on GitHub ↗

Route upserts a route to the API definition.

(method, pattern string)

Source from the content-addressed store, hash-verified

187
188// Route upserts a route to the API definition.
189func (api *API) Route(method, pattern string) (r *Route) {
190 methodToRoute, ok := api.Routes[Pattern(pattern)]
191 if !ok {
192 methodToRoute = make(MethodToRoute)
193 api.Routes[Pattern(pattern)] = methodToRoute
194 }
195 route, ok := methodToRoute[Method(method)]
196 if !ok {
197 route = &Route{
198 Method: Method(method),
199 Pattern: Pattern(pattern),
200 Models: Models{
201 Responses: make(map[int]Model),
202 },
203 Params: Params{
204 Path: make(map[string]PathParam),
205 Query: make(map[string]QueryParam),
206 },
207 }
208 methodToRoute[Method(method)] = route
209 }
210 return route
211}
212
213// Get defines a GET request route for the given pattern.
214func (api *API) Get(pattern string) (r *Route) {

Callers 11

MergeMethod · 0.95
GetMethod · 0.95
HeadMethod · 0.95
PostMethod · 0.95
PutMethod · 0.95
PatchMethod · 0.95
DeleteMethod · 0.95
ConnectMethod · 0.95
OptionsMethod · 0.95
TraceMethod · 0.95
TestSchemaFunction · 0.95

Calls 2

PatternTypeAlias · 0.85
MethodTypeAlias · 0.85

Tested by 1

TestSchemaFunction · 0.76