我正在使用 github.com/awslabs/aws-lambda-go-api-proxy/gin 創(chuàng)建 API。如果可能的話,我想從 gin.Context 中讀取 APIGatewayProxyRequest 或者請(qǐng)建議其他更好的方法?這是我的請(qǐng)求處理程序,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}這是我的發(fā)布請(qǐng)求處理程序,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貢獻(xiàn)2011條經(jīng)驗(yàn) 獲得超2個(gè)贊
我找到了解決方案,使用 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 關(guān)注
- 171 瀏覽
添加回答
舉報(bào)
0/150
提交
取消