awslabs / aws-lambda-go-api-proxy

lambda-go-api-proxy makes it easy to port APIs written with Go frameworks such as Gin (https://gin-gonic.github.io/gin/ ) to AWS Lambda and Amazon API Gateway.
Apache License 2.0
1.04k stars 197 forks source link

v2 HTTP API response header fix. #97

Closed aryounce closed 3 years ago

aryounce commented 3 years ago

This fix is related to #60 and possibly #75.

Description of changes:

The value for events.APIGatewayV2HTTPResponse.MultiValueHeaders is not being used by API Gateway v2 HTTP API instances and thus the returned headers are not passed through to the client. This change adds the value of each header in ProxyResponseWriterV2 to the events.APIGatewayV2HTTPResponse.Headers struct field.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

aryounce commented 3 years ago

I should also note that although MultiValueHeaders is a field in APIGatewayV2HTTPResponse the API Gateway documentation does not mention it as a part of v2 responses from Lambda integrations. See: Working with AWS Lambda proxy integrations for HTTP APIs, specifically: Lambda function response for format 2.0

To customize the response, your Lambda function should return a response with the following format.

{
    "cookies" : ["cookie1", "cookie2"],
    "isBase64Encoded": true|false,
    "statusCode": httpStatusCode,
    "headers": { "headername": "headervalue", ... },
    "body": "Hello from Lambda!"
}
aryounce commented 3 years ago

Closing as this is addressed by #99.