Skip to content

Commit

Permalink
Support both enable/disable attribute for multi value headers on ALB.
Browse files Browse the repository at this point in the history
Setting found in target groups of lambda type.
  • Loading branch information
fredericgermain committed Mar 25, 2021
1 parent 671f914 commit 64e9b7f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/event-sources/aws/alb.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,22 @@ const { getRequestValuesFromEvent, getMultiValueHeaders } = require('../utils')

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

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 @@ -141,6 +143,7 @@ async function forwardRequestToNodeServer ({
response,
resolver,
eventSource,
event,
log
})
return response
Expand Down

0 comments on commit 64e9b7f

Please sign in to comment.