我正在使用 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?
}
森林海
相关分类