|
|
|
@ -2052,6 +2052,9 @@ func TestNoMatchMethodErrorHandler(t *testing.T) { |
|
|
|
if resp.Code != http.StatusMethodNotAllowed { |
|
|
|
if resp.Code != http.StatusMethodNotAllowed { |
|
|
|
t.Errorf("Expecting code %v", 405) |
|
|
|
t.Errorf("Expecting code %v", 405) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if hdr := resp.Header().Get("Allow"); hdr != "GET,POST" { |
|
|
|
|
|
|
|
t.Errorf(`Expected Allow header to be "GET,POST" (got %q)`, hdr) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Add matching route
|
|
|
|
// Add matching route
|
|
|
|
r.HandleFunc("/", func1).Methods("PUT") |
|
|
|
r.HandleFunc("/", func1).Methods("PUT") |
|
|
|
@ -2721,7 +2724,6 @@ func TestMethodNotAllowed(t *testing.T) { |
|
|
|
handler := func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) } |
|
|
|
handler := func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) } |
|
|
|
router := NewRouter() |
|
|
|
router := NewRouter() |
|
|
|
router.HandleFunc("/thing", handler).Methods(http.MethodGet) |
|
|
|
router.HandleFunc("/thing", handler).Methods(http.MethodGet) |
|
|
|
router.HandleFunc("/something", handler).Methods(http.MethodGet) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
w := NewRecorder() |
|
|
|
w := NewRecorder() |
|
|
|
req := newRequest(http.MethodPut, "/thing") |
|
|
|
req := newRequest(http.MethodPut, "/thing") |
|
|
|
@ -2731,6 +2733,9 @@ func TestMethodNotAllowed(t *testing.T) { |
|
|
|
if w.Code != http.StatusMethodNotAllowed { |
|
|
|
if w.Code != http.StatusMethodNotAllowed { |
|
|
|
t.Fatalf("Expected status code 405 (got %d)", w.Code) |
|
|
|
t.Fatalf("Expected status code 405 (got %d)", w.Code) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if hdr := w.Header().Get("Allow"); hdr != http.MethodGet { |
|
|
|
|
|
|
|
t.Fatalf(`Expected Allow header to be "GET" (got %q)`, hdr) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
type customMethodNotAllowedHandler struct { |
|
|
|
type customMethodNotAllowedHandler struct { |
|
|
|
|