无服务器 alb 事件没有查询参数作为具有 multiValueQueryStringParameters 的列表:true

Serverless alb event does not have query params as a list with multiValueQueryStringParameters: true

所以我有一个无服务器应用程序,我将请求发送到一个 alb,它被重定向到一个 lambda 函数。我的要求是 /?filePath=a&filePath=b&filePath=c&filePath=d&pageSize=2 但在传递给 lambda 的情况下,其显示如下:-

  {
  "requestContext": {
      "elb": {
          "targetGroupArn": "xyz"
       }
   },
   "httpMethod": "GET",
   "path": "/xyz",
   "queryStringParameters": {
      "filePath": "d",
      "page": "1",
   },

所以,本质上不是将所有输入文件作为列表 event.mutliValueStringQueryParameters: ['a', 'b', 'c', 'd'],它只取最后一个元素作为queryParam。 我的 API 无服务器 alb 事件是这样的:-

- alb:
  listenerArn: XXX
  priority: 2
  multiValueQueryStringParameters: true
  conditions:
    path: XXX
  method: GET
- http:
  path: XXX
  method: GET

感谢任何帮助。

我自己还没有尝试过,但我认为您需要使用代理集成来获取 multiValueQueryStringParameters 字段。

https://aws.amazon.com/blogs/compute/support-for-multi-value-parameters-in-amazon-api-gateway/

https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html

请注意,select进行集成时,您可以选择负载版本。如果你 select 2 没有这样的代理限制,但你的值不是 multiValueQueryStringParameters,而是在一个逗号分隔的列表中连接在一起。

"filePath" : "a,b,c,d"