@@ -60,13 +60,17 @@ var _ = Describe("RequestAccessor tests", func() {
6060 Expect (binaryBody ).To (Equal (bodyBytes ))
6161 })
6262
63- qsRequest := getProxyRequest ("/hello" , "GET" )
64- qsRequest .MultiValueQueryStringParameters = map [string ][]string {
63+ mqsRequest := getProxyRequest ("/hello" , "GET" )
64+ mqsRequest .MultiValueQueryStringParameters = map [string ][]string {
6565 "hello" : {"1" },
6666 "world" : {"2" , "3" },
6767 }
68- It ("Populates query string correctly" , func () {
69- httpReq , err := accessor .EventToRequestWithContext (context .Background (), qsRequest )
68+ mqsRequest .QueryStringParameters = map [string ]string {
69+ "hello" : "1" ,
70+ "world" : "2" ,
71+ }
72+ It ("Populates multiple value query string correctly" , func () {
73+ httpReq , err := accessor .EventToRequestWithContext (context .Background (), mqsRequest )
7074 Expect (err ).To (BeNil ())
7175 Expect ("/hello" ).To (Equal (httpReq .URL .Path ))
7276 Expect ("GET" ).To (Equal (httpReq .Method ))
@@ -82,6 +86,29 @@ var _ = Describe("RequestAccessor tests", func() {
8286 Expect ("3" ).To (Equal (query ["world" ][1 ]))
8387 })
8488
89+ // Support `QueryStringParameters` for backward compatibility.
90+ // https://github.com/awslabs/aws-lambda-go-api-proxy/issues/37
91+ qsRequest := getProxyRequest ("/hello" , "GET" )
92+ qsRequest .QueryStringParameters = map [string ]string {
93+ "hello" : "1" ,
94+ "world" : "2" ,
95+ }
96+ It ("Populates query string correctly" , func () {
97+ httpReq , err := accessor .EventToRequestWithContext (context .Background (), qsRequest )
98+ Expect (err ).To (BeNil ())
99+ Expect ("/hello" ).To (Equal (httpReq .URL .Path ))
100+ Expect ("GET" ).To (Equal (httpReq .Method ))
101+
102+ query := httpReq .URL .Query ()
103+ Expect (2 ).To (Equal (len (query )))
104+ Expect (query ["hello" ]).ToNot (BeNil ())
105+ Expect (query ["world" ]).ToNot (BeNil ())
106+ Expect (1 ).To (Equal (len (query ["hello" ])))
107+ Expect (1 ).To (Equal (len (query ["world" ])))
108+ Expect ("1" ).To (Equal (query ["hello" ][0 ]))
109+ Expect ("2" ).To (Equal (query ["world" ][0 ]))
110+ })
111+
85112 basePathRequest := getProxyRequest ("/app1/orders" , "GET" )
86113
87114 It ("Stips the base path correct" , func () {
0 commit comments