我正在使用 github.com/awslabs/aws-lambda-go-api-proxy/gin 创建 API。如果可能的话,我想从 gin.Context 中读取 APIGatewayProxyRequest 或者请建议其他更好的方法?这是我的请求处理程序,func handleRequest(ctx context.Context, req *events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) { db := persistence.InitializeDB() defer db.Close() router := router.NewApiRouter() if ginLambda == nil { ginLambda = gin.New(router.Initialize()) // here I send req to router, which I want to use in endpoint handler } response, err := ginLambda.ProxyWithContext(ctx, *req) ... return response, err}这是我的发布请求处理程序,func (ser *Service) GetUserRecordByID(context *gin.Context) {// here I want to read APIGatewayProxyRequest object. I can log context, but not sure how to read APIGatewayProxyRequest object? }
1 回答

森林海
TA贡献2011条经验 获得超2个赞
我找到了解决方案,使用 aws lambda 代理核心..
import (
"github.com/awslabs/aws-lambda-go-api-proxy/core"
)
func (ser *Service) GetUserRecordByID(context *gin.Context) {
apiGWRequestContext, ok := core.GetAPIGatewayContextFromContext(c.Request.Context())
}
- 1 回答
- 0 关注
- 177 浏览
添加回答
举报
0/150
提交
取消