如何在AWS Lambda函数中获取AWS API Gateway调用URL? [英] How to get AWS API Gateway invoke URL in an AWS Lambda function?
问题描述
我正在将代理集成与Java lambda函数一起使用. lambda处理程序的输入是一个JSON对象,它表示传入的请求.它具有正文,标题,查询参数等.但是它不包括API网关为正文,查询参数等解析的源URL.有没有办法获取它?
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?
问题是API网关不支持查询参数中的数组.示例:/endpoint?numbers=1&numbers=2
.似乎,传递数组的唯一方法是将其作为JSON数组字符串/endpoint?numbers=[1,2]
传递,但并不总是合适的.所以我想自己解析URL.
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.
推荐答案
不幸的是,API Gateway并没有为您提供完整的URL来解析您自己.
Unfortunately, API Gateway doesn't provide you with the full URL for you to parse yourself.
如果可以选择将POST
方法用于/endpoint
,则可以考虑发送请求正文而不是查询字符串参数.
If you have the option of using the POST
method to /endpoint
, you might consider sending a request body instead of query string parameters.
这篇关于如何在AWS Lambda函数中获取AWS API Gateway调用URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!