How to get the HTTP method in AWS Lambda?

后端 未结 3 797
没有蜡笔的小新
没有蜡笔的小新 2021-01-04 06:26

In an AWS Lambda code, how can I get the HTTP method (e.g. GET, POST...) of an HTTP request coming from the AWS Gateway API?

I understand from the documentation tha

3条回答
  •  日久生厌
    2021-01-04 06:49

    API Gateway now has a built-in mapping template that passes along stuff like http method, route, and a lot more. I can't embed because I don't have enough points, but you get the idea.

    Here is a screenshot of how you add it in the API Gateway console:

    To get there navigate to AWS Console > API Gateway > (select a resource, IE - GET /home) > Integration Request > Mapping Templates > Then click on application/json and select Method Request Passthrough from dropdown shown in the screenshot above

提交回复
热议问题