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.05k stars 197 forks source link

Override DefaultServerAddress from APIGatewayProxyRequest #46

Closed smcstewart closed 4 years ago

smcstewart commented 5 years ago

I know this has been looked at previously in #13 and associated PR, but with API GW returning the host, is there any reason not to default to the host as passed in the APIGatewayProxyRequest instead of the DefaultServerAddress? I can understand https://aws-serverless-go-api.com being a fallback if no host is passed from API GW, but defaulting to the actual host would get us closer to the integrity of the original http request.

kddejong commented 4 years ago

Agreed. Setting GO_API_HOST appears to require a change to the router configuration as the API Gateway stage comes into play.

It would be nice if the https://godoc.org/github.com/aws/aws-lambda-go/events#APIGatewayProxyRequestContext request context could be passed through if this can't be changed along with https://golang.org/pkg/net/http/#NewRequestWithContext

RaeesBhatti commented 4 years ago

I recently added DomainName and some other properties to APIGatewayProxyRequestContext type in aws-lambda-go. The changes have been published in v1.17.0. This allows domain name to be inferred from APIGatewayProxyRequestContext.DomainName.

Please upvote the PR here: https://github.com/awslabs/aws-lambda-go-api-proxy/pull/67