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.06k stars 198 forks source link

Support v2 payloads for `httpadapter` #112

Closed danielwhite closed 2 years ago

danielwhite commented 2 years ago

https://github.com/awslabs/aws-lambda-go-api-proxy/pull/80 implemented support for handlerfunc but not httpadapter.

This provides an equivalent implementation to handlerfunc.HandlerFuncAdapterV2 that will proxy events.APIGatewayV2HTTPRequest to a http.Handler.

A http.HandlerFunc implements the http.Handler interface so I've implemented handlerfunc in terms of httpadapter. This will avoid implementation drift. To avoid breaking backwards compatibility, this uses type aliases and preserves the handlerfunc.New and handlerfunc.NewV2 methods.

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