-
Notifications
You must be signed in to change notification settings - Fork 204
Conversation
echo/adapter.go
Outdated
@@ -17,6 +17,7 @@ import ( | |||
// creates a proxy response object from the http.ResponseWriter | |||
type EchoLambda struct { | |||
core.RequestAccessor | |||
v2 core.RequestAccessorV2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to separate V2 like the Gin adapter (since that is already in) - https://github.com/awslabs/aws-lambda-go-api-proxy/tree/master/gin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I didn't see that one! I think my personal preference would be separate. But it appears there is not any consistency!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seeing as Gin is one of the main framework examples for this project I think it makes sense to follow the same pattern, will refactor 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have refactored to match the pattern set in the Gin adapter
Any update for this PR? |
@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.