How to get AWS API Gateway invoke URL in an AWS Lambda function?

淺唱寂寞╮ 提交于 2019-12-11 02:59:28

问题


I'm using the proxy integration with my Java lambda function. The input for the lambda handler is a JSON object that represents an incoming request. It has a body, headers, query params and so on. But it doesn't include the source URL that is parsed by the API Gateway for the body, query params and etc. Is there a way to get it?

The thing is API Gateway doesn't support arrays in query parameters. Example: /endpoint?numbers=1&numbers=2. Seems, the only way to pass an array is to pass it as a JSON array string /endpoint?numbers=[1,2] but it is not always suitable. So I want to parse the URL by myself.


回答1:


Unfortunately, API Gateway doesn't provide you with the full URL for you to parse yourself.

If you have the option of using the POST method to /endpoint, you might consider sending a request body instead of query string parameters.




回答2:


The 'path' field inside the 'requestContext' field contains the path of API gateway resource. See docs for more details.



来源:https://stackoverflow.com/questions/49372722/how-to-get-aws-api-gateway-invoke-url-in-an-aws-lambda-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!