@@ -60,13 +60,17 @@ var _ = Describe("RequestAccessor tests", func() {
60
60
Expect (binaryBody ).To (Equal (bodyBytes ))
61
61
})
62
62
63
- qsRequest := getProxyRequest ("/hello" , "GET" )
64
- qsRequest .MultiValueQueryStringParameters = map [string ][]string {
63
+ mqsRequest := getProxyRequest ("/hello" , "GET" )
64
+ mqsRequest .MultiValueQueryStringParameters = map [string ][]string {
65
65
"hello" : {"1" },
66
66
"world" : {"2" , "3" },
67
67
}
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 )
70
74
Expect (err ).To (BeNil ())
71
75
Expect ("/hello" ).To (Equal (httpReq .URL .Path ))
72
76
Expect ("GET" ).To (Equal (httpReq .Method ))
@@ -82,6 +86,29 @@ var _ = Describe("RequestAccessor tests", func() {
82
86
Expect ("3" ).To (Equal (query ["world" ][1 ]))
83
87
})
84
88
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
+
85
112
basePathRequest := getProxyRequest ("/app1/orders" , "GET" )
86
113
87
114
It ("Stips the base path correct" , func () {
0 commit comments