8000 add query fallback support for alb multi-value · jthomerson/lambda-api@e572f6c · GitHub
[go: up one dir, main page]

Skip to content

Commit e572f6c

Browse files
committed
add query fallback support for alb multi-value
1 parent 09f6596 commit e572f6c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/request.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,19 @@ class REQUEST {
6767
// Set the path
6868
this.path = this.app._event.path
6969

70-
// Set the query parameters
71-
this.query = Object.assign({}, this.app._event.queryStringParameters)
70+
// Set the query parameters (backfill for ALB)
71+
this.query = Object.assign({}, this.app._event.queryStringParameters,
72+
'queryStringParameters' in this.app._event ? {} // do nothing
73+
: Object.assign({},Object.keys(this.app._event.multiValueQueryStringParameters)
74+
.reduce((qs,key) => Object.assign(qs, // get the last value of the array
75+
{ [key]: this.app._event.multiValueQueryStringParameters[key].slice(-1)[0] }
76+
), {}))
77+
)
7278

7379
// Set the multi-value query parameters (simulate if no mult-value support)
7480
this.multiValueQuery = Object.assign({},
7581
this._multiValueSupport ? {} : Object.keys(this.query)
76-
.reduce((qs,key) => Object.assign(qs, { [key]: [this.query[key]] }),{}),
82+
.reduce((qs,key) => Object.assign(qs, { [key]: [this.query[key]] }), {}),
7783
this.app._event.multiValueQueryStringParameters)
7884

7985
// Set the raw headers

0 commit comments

Comments
 (0)
0