-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Description
Is there an existing feature request for this?
- I have searched the existing feature requests
Is your feature request related to a problem? Please describe.
If a client is (mis)configured to make requests with lowercase method names, it is impossible to use gorilla/mux to match.
Describe the solution that you would like.
Case insensitive matches on methods.
Describe alternatives you have considered.
One way is to stop strings.ToUpper
-ing defined methods, but that would break compatibility. Documenting the current limitation if the behavior is not changed would also go far.
Anything else?
A test case that demonstrates the condition:
func TestLowercaseMethods(t *testing.T) {
r := mux.NewRouter()
r.HandleFunc("/hc", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
}).Methods("get", "GET")
methods := []string{"get", "GET"}
for i := range methods {
w := httptest.NewRecorder()
r.ServeHTTP(w, httptest.NewRequest(methods[i], "/hc", nil))
t.Logf("Method %q: got %d", methods[i], w.Result().StatusCode)
}
}
// Method "get": got 405
// Method "GET": got 200
Also, thanks!
jackgris
Metadata
Metadata
Assignees
Labels
No labels