MCPcopy
hub / github.com/go-chi/chi / setEndpoint

Method setEndpoint

tree.go:344–372  ·  view source on GitHub ↗
(method methodTyp, handler http.Handler, pattern string)

Source from the content-addressed store, hash-verified

342}
343
344func (n *node) setEndpoint(method methodTyp, handler http.Handler, pattern string) {
345 // Set the handler for the method type on the node
346 if n.endpoints == nil {
347 n.endpoints = make(endpoints)
348 }
349
350 paramKeys := patParamKeys(pattern)
351
352 if method&mSTUB == mSTUB {
353 n.endpoints.Value(mSTUB).handler = handler
354 }
355 if method&mALL == mALL {
356 h := n.endpoints.Value(mALL)
357 h.handler = handler
358 h.pattern = pattern
359 h.paramKeys = paramKeys
360 for _, m := range methodMap {
361 h := n.endpoints.Value(m)
362 h.handler = handler
363 h.pattern = pattern
364 h.paramKeys = paramKeys
365 }
366 } else {
367 h := n.endpoints.Value(method)
368 h.handler = handler
369 h.pattern = pattern
370 h.paramKeys = paramKeys
371 }
372}
373
374func (n *node) FindRoute(rctx *Context, method methodTyp, path string) (*node, endpoints, http.Handler) {
375 // Reset the context routing pattern and params

Callers 1

InsertRouteMethod · 0.95

Calls 2

patParamKeysFunction · 0.85
ValueMethod · 0.80

Tested by

no test coverage detected