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

Function methodNotAllowedHandler

mux.go:518–526  ·  mux.go::methodNotAllowedHandler

methodNotAllowedHandler is a helper function to respond with a 405, method not allowed. It sets the Allow header with the list of allowed methods for the route.

(methodsAllowed ...methodTyp)

Source from the content-addressed store, hash-verified

516// method not allowed. It sets the Allow header with the list of allowed
517// methods for the route.
518func methodNotAllowedHandler(methodsAllowed ...methodTyp) func(w http.ResponseWriter, r *http.Request) {
519 return func(w http.ResponseWriter, r *http.Request) {
520 for _, m := range methodsAllowed {
521 w.Header().Add("Allow", reverseMethodMap[m])
522 }
523 w.WriteHeader(405)
524 w.Write(nil)
525 }
526}

Callers 1

Calls 3

AddMethod · 0.80
WriteMethod · 0.65
WriteHeaderMethod · 0.45

Tested by

no test coverage detected