MCPcopy
hub / github.com/julienschmidt/httprouter / Lookup

Method Lookup

router.go:320–325  ·  view source on GitHub ↗

Lookup allows the manual lookup of a method + path combo. This is e.g. useful to build a framework around this router. If the path was found, it returns the handle function and the path parameter values. Otherwise the third return value indicates whether a redirection to the same path with an extra

(method, path string)

Source from the content-addressed store, hash-verified

318// values. Otherwise the third return value indicates whether a redirection to
319// the same path with an extra / without the trailing slash should be performed.
320func (r *Router) Lookup(method, path string) (Handle, Params, bool) {
321 if root := r.trees[method]; root != nil {
322 return root.getValue(path)
323 }
324 return nil, nil, false
325}
326
327func (r *Router) allowed(path, reqMethod string) (allow string) {
328 allowed := make([]string, 0, 9)

Callers 1

TestRouterLookupFunction · 0.80

Calls 1

getValueMethod · 0.80

Tested by 1

TestRouterLookupFunction · 0.64