@@ -62,6 +62,10 @@ type bindTestStruct struct {
6262 SA StringArray
6363}
6464
65+ type bindQueryArrayTestStruct struct {
66+ Foo []string `query:"foo"`
67+ }
68+
6569type bindTestStructWithTags struct {
6670 I int `json:"I" form:"I"`
6771 PtrI * int `json:"PtrI" form:"PtrI"`
@@ -275,6 +279,30 @@ func TestBindQueryParamsCaseSensitivePrioritized(t *testing.T) {
275279 }
276280}
277281
282+ func TestBindQueryArrayParams (t * testing.T ) {
283+ e := New ()
284+ req := httptest .NewRequest (http .MethodGet , "/?foo=one&foo=two" , nil )
285+ rec := httptest .NewRecorder ()
286+ c := e .NewContext (req , rec )
287+ q := new (bindQueryArrayTestStruct )
288+ err := c .Bind (q )
289+ if assert .NoError (t , err ) {
290+ assert .Equal (t , []string {"one" , "two" }, q .Foo )
291+ }
292+ }
293+
294+ func TestBindQueryArrayParamsWithSuffix (t * testing.T ) {
295+ e := New ()
296+ req := httptest .NewRequest (http .MethodGet , "/?foo[]=one&foo[]=two" , nil )
297+ rec := httptest .NewRecorder ()
298+ c := e .NewContext (req , rec )
299+ q := new (bindQueryArrayTestStruct )
300+ err := c .Bind (q )
301+ if assert .NoError (t , err ) {
302+ assert .Equal (t , []string {"one" , "two" }, q .Foo )
303+ }
304+ }
305+
278306func TestBindHeaderParam (t * testing.T ) {
279307 e := New ()
280308 req := httptest .NewRequest (http .MethodGet , "/" , nil )
0 commit comments