mux.go
func (mx *Mux) NotFound(handlerFn http.HandlerFunc) {
	// Build NotFound handler chain
	m := mx
	hFn := handlerFn
	if mx.inline && mx.parent != nil {
		m = mx.parent
		hFn = Chain(mx.middlewares...).HandlerFunc(hFn).ServeHTTP
	}

	// Update the notFoundHandler from this point forward
	m.notFoundHandler = hFn
	m.updateSubRoutes(func(subMux *Mux) {
		if subMux.notFoundHandler == nil {
			subMux.NotFound(hFn)
		}
	})
}
func (mx *Mux) NotFound(handlerFn http.HandlerFunc) {
	// Build NotFound handler chain
	m := mx
	hFn := handlerFn
	if mx.inline && mx.parent != nil {
		m = mx.parent
		hFn = Chain(mx.middlewares...).HandlerFunc(hFn).ServeHTTP
	}

	// Update the notFoundHandler from this point forward
	m.notFoundHandler = hFn
	m.updateSubRoutes(func(subMux *Mux) {
		if subMux.notFoundHandler == nil {
			subMux.NotFound(hFn)
		}
	})
}
func ( mx * Mux ) NotFound ( handlerFn http . HandlerFunc ) { // Build NotFound handler chain m := mx hFn := handlerFn if mx . inline && mx . parent != nil { m = mx . parent hFn = Chain ( mx . middlewares ... ) . HandlerFunc ( hFn ) . ServeHTTP } // Update the notFoundHandler from this point forward m . notFoundHandler = hFn m . updateSubRoutes ( func ( subMux * Mux ) { if subMux . notFoundHandler == nil { subMux . NotFound ( hFn ) } } ) }
// NotFound sets a custom http.HandlerFunc for routing paths that could
// not be found. The default 404 handler is `http.NotFound`.
NotFound sets a custom http . HandlerFunc for routing paths that could not be found . The default 404 handler is http . NotFound .