Parse URL params using API Gateway and lambda
Lambda script
Lambda could collect POST boday and url params using event
. For POST body, params could be extracted directly like event['param1']
.
As of September 2017, you no longer have to configure mappings to access the request body.
All you need to do is check, “Use Lambda Proxy integration”, under Integration Request, under the resource of AWS API Gateway.
You’ll then be able to access query parameters, path parameters and headers like so
1 | event['pathParameters']['param1'] |
For proxied API, the hander function should return the reponse in following format:
1 | { |
Usually, when you see Malformed Lambda proxy response, it means your response from your Lambda function doesn’t match the format API Gateway is expecting.
专题:
timeline
本文发表于 2020-03-12,最后修改于 2020-03-13。
本站永久域名「 jevy.wang 」,也可搜索「 Jevy Wang's Blog 」找到我。
期待关注我的 「 知乎专栏 」 ,查看最近的文章和动态。
上一篇 « Add an image layer to react mapbox gl 下一篇 » IP Camera BAT 310 Hacking