dougmoscrop / serverless-http

Use your existing middleware framework (e.g. Express, Koa) in AWS Lambda 🎉
Other
1.71k stars 164 forks source link

fix: use correct key for headers on alb responses when multiValueHeaders is set #283

Closed liamchilds closed 10 months ago

liamchilds commented 11 months ago

There is a bug/missing functionality in the library currently when trying to set headers on the response when using an ALB Lambda trigger with multiValueHeaders.

In the case of an ALB event

Responses with multi-value headers

The names of the fields used for headers differ depending on whether you enable multi-value headers for the target group. You must use multiValueHeaders if you have enabled multi-value headers and headers otherwise.

The current implementation will return single value headers in the headers key which means if multiValueHeaders are enabled those headers go missing.

This PR aims to resolve the above issue and clean up the format function so that it can handle response formats for HTTP apis (V1 and V2) as well as ALB style responses.

liamchilds commented 10 months ago

Hi @dougmoscrop do you have any time to review the above?

dougmoscrop commented 10 months ago

Yes, sorry, I will today or tomorrow!

dougmoscrop commented 10 months ago

Haven't forgot, just got caught up in stuff

liamchilds commented 10 months ago

No problem!