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

Method Handle

router.go:244–262  ·  router.go::Router.Handle

Handle registers a new request handle with the given path and method. For GET, POST, PUT, PATCH and DELETE requests the respective shortcut functions can be used. This function is intended for bulk loading and to allow the usage of less frequently used, non-standardized or custom methods (e.g. for

(method, path string, handle Handle)

Source from the content-addressed store, hash-verified

242// frequently used, non-standardized or custom methods (e.g. for internal
243// communication with a proxy).
244func (r *Router) Handle(method, path string, handle Handle) {
245 if len(path) < 1 || path[0] != '/' {
246 panic("path must begin with '/' in path '" + path + "'")
247 }
248
249 if r.trees == nil {
250 r.trees = make(map[string]*node)
251 }
252
253 root := r.trees[method]
254 if root == nil {
255 root = new(node)
256 r.trees[method] = root
257
258 r.globalAllowed = r.allowed("*", "")
259 }
260
261 root.addRoute(path, handle)
262}
263
264// Handler is an adapter which allows the usage of an http.Handler as a
265// request handle.

Callers 10

GETMethod · 0.95
HEADMethod · 0.95
OPTIONSMethod · 0.95
POSTMethod · 0.95
PUTMethod · 0.95
PATCHMethod · 0.95
DELETEMethod · 0.95
HandlerMethod · 0.95
TestRouterFunction · 0.80
TestRouterPanicHandlerFunction · 0.80

Calls 2

allowedMethod · 0.95
addRouteMethod · 0.80

Tested by 2

TestRouterFunction · 0.64
TestRouterPanicHandlerFunction · 0.64