Skip to content

Commit

Permalink
feat: support both enable/disable attribute for multi value headers o…
Browse files Browse the repository at this point in the history
…n ALB (CodeGenieApp#392)
  • Loading branch information
fredericgermain committed Oct 13, 2021
1 parent 37539fb commit a5cb5b5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/event-sources/aws/alb.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,24 @@ const getRequestValuesFromAlbEvent = ({ event }) => {
}

const getResponseToAlb = ({
event,
statusCode,
body,
headers,
headers: responseHeaders,
isBase64Encoded
}) => {
const multiValueHeaders = getMultiValueHeaders({ headers })
const multiValueHeaders = !event.headers ? getMultiValueHeaders({ headers: responseHeaders }) : undefined
const headers = event.headers
? Object.entries(responseHeaders).reduce((acc, [k, v]) => {
acc[k] = Array.isArray(v) ? v[0] : v
return acc
}, {})
: undefined

return {
statusCode,
body,
headers,
multiValueHeaders,
isBase64Encoded
}
Expand Down
3 changes: 3 additions & 0 deletions src/transport.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ function forwardResponse ({
response,
resolver,
eventSource,
event,
log
}) {
const statusCode = response.statusCode
Expand All @@ -30,6 +31,7 @@ function forwardResponse ({
})

const successResponse = eventSource.getResponse({
event,
statusCode,
body,
headers,
Expand Down Expand Up @@ -158,6 +160,7 @@ async function forwardRequestToNodeServer ({
response,
resolver,
eventSource,
event,
log
})
return response
Expand Down

0 comments on commit a5cb5b5

Please sign in to comment.