RegisterMethod adds support for custom HTTP method handlers, available via Router#Method and Router#MethodFunc
(method string)
| 59 | // RegisterMethod adds support for custom HTTP method handlers, available |
| 60 | // via Router#Method and Router#MethodFunc |
| 61 | func 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 | |
| 79 | type nodeTyp uint8 |
| 80 |