Closed AlexLast closed 2 years ago
Any update for this PR? This works fine for me.
Any update for this PR? This works fine for me.
@yasuoza Unfortunately It's still waiting for a review, currently I'm just using my own build
FYI: Bypass to echo.ServeHTTP also works. This may be useful until this PR is merged.
package main
import (
"context"
"log"
"net/http"
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
"github.com/awslabs/aws-lambda-go-api-proxy/handlerfunc"
"github.com/labstack/echo/v4"
)
var (
httpLambda *handlerfunc.HandlerFuncAdapterV2
)
func init() {
// stdout and stderr are sent to AWS CloudWatch Logs
log.Printf("echo cold start")
e := echo.New()
e.GET("/", func(c echo.Context) error {
return c.JSON(http.StatusOK, map[string]string{"message": "pong"})
})
httpLambda = handlerfunc.NewV2(e.ServeHTTP)
}
// Handler handles request from API Gateway V2
func Handler(ctx context.Context, req events.APIGatewayV2HTTPRequest) (events.APIGatewayV2HTTPResponse, error) {
return httpLambda.ProxyWithContext(ctx, req)
}
func main() {
lambda.Start(Handler)
}
Issue #, if available:
Description of changes: Adds support for API Gateway HTTP V2 payloads for the Echo framework
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.