NotFound sets a custom http.HandlerFunc for routing paths that could not be found. The default 404 handler is `http.NotFound`.
(handlerFn http.HandlerFunc)
| 195 | // NotFound sets a custom http.HandlerFunc for routing paths that could |
| 196 | // not be found. The default 404 handler is `http.NotFound`. |
| 197 | func (mx *Mux) NotFound(handlerFn http.HandlerFunc) { |
| 198 | // Build NotFound handler chain |
| 199 | m := mx |
| 200 | hFn := handlerFn |
| 201 | if mx.inline && mx.parent != nil { |
| 202 | m = mx.parent |
| 203 | hFn = Chain(mx.middlewares...).HandlerFunc(hFn).ServeHTTP |
| 204 | } |
| 205 | |
| 206 | // Update the notFoundHandler from this point forward |
| 207 | m.notFoundHandler = hFn |
| 208 | m.updateSubRoutes(func(subMux *Mux) { |
| 209 | if subMux.notFoundHandler == nil { |
| 210 | subMux.NotFound(hFn) |
| 211 | } |
| 212 | }) |
| 213 | } |
| 214 | |
| 215 | // MethodNotAllowed sets a custom http.HandlerFunc for routing paths where the |
| 216 | // method is unresolved. The default handler returns a 405 with an empty body. |
nothing calls this directly
no test coverage detected