Open
Description
When bone returns a 405 Method Not Allowed response, it would be good if it could include an Allow header detailing which methods are permitted.
I think it could perhaps be done by amending the otherMethods
helper. Something like:
func (m *Mux) otherMethods(rw http.ResponseWriter, req *http.Request) bool {
allowed := []string{}
for _, met := range method {
if met != req.Method {
for _, r := range m.Routes[met] {
ok := r.exists(rw, req)
if ok {
allowed = append(allowed, r.Method)
}
}
}
}
if len(allowed) > 0 {
rw.Header()["Allow"] = allowed
rw.WriteHeader(http.StatusMethodNotAllowed)
return true
}
return false
}
Also, what are your thoughts on including a plain text "Method Not Allowed" message in the response body, similar to the "404 page not allowed" body for 404s?
Metadata
Metadata
Assignees
Labels
No labels