mirror of
https://github.com/labstack/echo.git
synced 2025-06-19 00:27:34 +02:00
Enable case insensitive query param matching
Unmarshalling body params with json.Unmarshal supports case-insensitive matching against struct tags. Matching query params case insensitive provides a more sane and consistent experience for API consumers. The original url.Values keys remain case sensitive.
This commit is contained in:
committed by
Vishal Rana
parent
ec7b497940
commit
01cfe83efe
13
bind_test.go
13
bind_test.go
@ -152,6 +152,19 @@ func TestBindQueryParams(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestBindQueryParamsCaseInsensitive(t *testing.T) {
|
||||
e := New()
|
||||
req := httptest.NewRequest(GET, "/?ID=1&NAME=Jon+Snow", nil)
|
||||
rec := httptest.NewRecorder()
|
||||
c := e.NewContext(req, rec)
|
||||
u := new(user)
|
||||
err := c.Bind(u)
|
||||
if assert.NoError(t, err) {
|
||||
assert.Equal(t, 1, u.ID)
|
||||
assert.Equal(t, "Jon Snow", u.Name)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBindUnmarshalParam(t *testing.T) {
|
||||
e := New()
|
||||
req := httptest.NewRequest(GET, "/?ts=2016-12-06T19:09:05Z&sa=one,two,three&ta=2016-12-06T19:09:05Z&ta=2016-12-06T19:09:05Z&ST=baz", nil)
|
||||
|
Reference in New Issue
Block a user