@@ -64,7 +64,7 @@ func (pr *patRouter) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
allow, ok := pr.methodNotAllowed(r.Method, reqPath)
|
allows, ok := pr.methodsAllowed(r.Method, reqPath)
|
||||||
if !ok {
|
if !ok {
|
||||||
pr.handleNotFound(w, r)
|
pr.handleNotFound(w, r)
|
||||||
return
|
return
|
||||||
@@ -73,7 +73,7 @@ func (pr *patRouter) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
if pr.notAllowed != nil {
|
if pr.notAllowed != nil {
|
||||||
pr.notAllowed.ServeHTTP(w, r)
|
pr.notAllowed.ServeHTTP(w, r)
|
||||||
} else {
|
} else {
|
||||||
w.Header().Set(allowHeader, allow)
|
w.Header().Set(allowHeader, allows)
|
||||||
w.WriteHeader(http.StatusMethodNotAllowed)
|
w.WriteHeader(http.StatusMethodNotAllowed)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -94,7 +94,7 @@ func (pr *patRouter) handleNotFound(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pr *patRouter) methodNotAllowed(method, path string) (string, bool) {
|
func (pr *patRouter) methodsAllowed(method, path string) (string, bool) {
|
||||||
var allows []string
|
var allows []string
|
||||||
|
|
||||||
for treeMethod, tree := range pr.trees {
|
for treeMethod, tree := range pr.trees {
|
||||||
|
|||||||
Reference in New Issue
Block a user