fix: type matching supports string to int (#2038)
* fix: type matching supports string to int * feat: type matching supports string to int Co-authored-by: 程家福 <chengjiafu@uniontech.com>
This commit is contained in:
@@ -38,3 +38,14 @@ func TestParseHeadersMulti(t *testing.T) {
|
||||
assert.Equal(t, 1, val.Baz)
|
||||
assert.True(t, val.Qux)
|
||||
}
|
||||
|
||||
func TestParseHeadersArrayInt(t *testing.T) {
|
||||
var val struct {
|
||||
Foo []int `header:"foo"`
|
||||
}
|
||||
r := httptest.NewRequest(http.MethodGet, "/any", nil)
|
||||
r.Header.Set("foo", "1")
|
||||
r.Header.Add("foo", "2")
|
||||
assert.Nil(t, ParseHeaders(r.Header, &val))
|
||||
assert.Equal(t, []int{1, 2}, val.Foo)
|
||||
}
|
||||
Reference in New Issue
Block a user