You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[bug] Adding to GET the same endpoint with POST and different Queries ends up with inconsistent error messages #704
// You can edit this code!// Click here and start typing.package main
import (
"encoding/json""fmt""net/http""net/http/httptest""time""github.com/gorilla/mux"
)
funcmain() {
r:=mux.NewRouter()
r.HandleFunc("/api/v2", func(w http.ResponseWriter, r*http.Request) {
// an example API handlerfmt.Fprintf(w, "You made a POST request")
json.NewEncoder(w).Encode(map[string]bool{"ok": true})
}).Methods("POST")
r.HandleFunc("/api/v2", func(w http.ResponseWriter, r*http.Request) {
// an example API handlerfmt.Fprintf(w, "You made a GET request")
json.NewEncoder(w).Encode(map[string]bool{"ok": true})
}).
Queries("from", "{from:[0-9]+}",
"to", "{to:[0-9]+}").Methods("GET")
srv:=&http.Server{
Handler: r,
Addr: "127.0.0.1:8000",
// Good practice: enforce timeouts for servers you create!WriteTimeout: 15*time.Second,
ReadTimeout: 15*time.Second,
}
gosrv.ListenAndServe()
req2:=httptest.NewRequest("GET", "/api/v2?from=3&to=-5", nil)
out2:=httptest.NewRecorder()
r.ServeHTTP(out2, req2)
fmt.Println(out2.Code)
fmt.Println(out2)
}
// You can edit this code!// Click here and start typing.package main
import (
"encoding/json""fmt""net/http""net/http/httptest""time""github.com/gorilla/mux"
)
funcmain() {
r:=mux.NewRouter()
r.HandleFunc("/api/v2", func(w http.ResponseWriter, r*http.Request) {
// an example API handlerfmt.Fprintf(w, "You made a GET request")
json.NewEncoder(w).Encode(map[string]bool{"ok": true})
}).
Queries("from", "{from:[0-9]+}",
"to", "{to:[0-9]+}").Methods("GET")
srv:=&http.Server{
Handler: r,
Addr: "127.0.0.1:8000",
// Good practice: enforce timeouts for servers you create!WriteTimeout: 15*time.Second,
ReadTimeout: 15*time.Second,
}
gosrv.ListenAndServe()
req2:=httptest.NewRequest("GET", "/api/v2?from=3&to=-5", nil)
out2:=httptest.NewRecorder()
r.ServeHTTP(out2, req2)
fmt.Println(out2.Code)
}
Result is
404
Expected behavior
Both cases should end in only 404-s
changed the title [-][bug] Adding the same endpoint POST with different Queries ends up with incosnsistent error messages[/-][+][bug] Adding the same endpoint POST with different Queries ends up with inconsistent error messages[/+]on Dec 7, 2022
changed the title [-][bug] Adding the same endpoint POST with different Queries ends up with inconsistent error messages[/-][+][bug] Adding to GET the same endpoint with POST and different Queries ends up with inconsistent error messages[/+]on Dec 7, 2022
Activity
[-][bug] Adding the same endpoint POST with different Queries ends up with incosnsistent error messages[/-][+][bug] Adding the same endpoint POST with different Queries ends up with inconsistent error messages[/+][-][bug] Adding the same endpoint POST with different Queries ends up with inconsistent error messages[/-][+][bug] Adding to GET the same endpoint with POST and different Queries ends up with inconsistent error messages[/+][BUG] Inconsistent HTTP status code on query mismatch
[BUG] Inconsistent HTTP status code on query mismatch
[BUG] Inconsistent HTTP status code on query mismatch (#712)