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

Method NotFound

mux.go:197–213  ·  view source on GitHub ↗

NotFound sets a custom http.HandlerFunc for routing paths that could not be found. The default 404 handler is `http.NotFound`.

(handlerFn http.HandlerFunc)

Source from the content-addressed store, hash-verified

195// NotFound sets a custom http.HandlerFunc for routing paths that could
196// not be found. The default 404 handler is `http.NotFound`.
197func (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.

Callers

nothing calls this directly

Calls 4

ChainFunction · 0.85
HandlerFuncMethod · 0.80
updateSubRoutesMethod · 0.80
NotFoundMethod · 0.65

Tested by

no test coverage detected