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

Function RegisterMethod

tree.go:61–77  ·  view source on GitHub ↗

RegisterMethod adds support for custom HTTP method handlers, available via Router#Method and Router#MethodFunc

(method string)

Source from the content-addressed store, hash-verified

59// RegisterMethod adds support for custom HTTP method handlers, available
60// via Router#Method and Router#MethodFunc
61func RegisterMethod(method string) {
62 if method == "" {
63 return
64 }
65 method = strings.ToUpper(method)
66 if _, ok := methodMap[method]; ok {
67 return
68 }
69 n := len(methodMap)
70 if n > strconv.IntSize-2 {
71 panic(fmt.Sprintf("chi: max number of methods reached (%d)", strconv.IntSize))
72 }
73 mt := methodTyp(2 << n)
74 methodMap[method] = mt
75 reverseMethodMap[mt] = method
76 mALL |= mt
77}
78
79type nodeTyp uint8
80

Callers 1

TestCustomHTTPMethodFunction · 0.85

Calls 1

methodTypTypeAlias · 0.85

Tested by 1

TestCustomHTTPMethodFunction · 0.68