如果 Spring Boot 应用程序部署为 AWS lambda 函数,则 GET 请求的查询参数将被截断为最后一个值

问题描述 投票:0回答:1

我将以下请求发送到部署为 AWS lambda 函数的 Spring Boot 应用程序:

GET https://my-dev-host.com/fdx/v6/accounts?accountIds=confUser_1&accountIds=confUser_2&accountIds=confUser_3&accountIds=confUser_4&offset=1&limit=3
Authorization: Bearer ....
Accept: application/json
Accept-Charset: UTF-8
Content-Type: application/json

但是在日志中我看到只有最后一个

accountId
实际上到达了控制器:

Modified request:
{
  "multiValueQueryStringParameters": {
    "accountIds": [
      "confUser_4"
    ],
    "limit": [
      "3"
    ],
    "offset": [
      "1"
    ]
  },
  "queryStringParameters": {
    "accountIds": "confUser_4",
    "limit": "3",
    "offset": "1"
  },
  "multiValueHeaders": {
    "accept": [
      "application/json"
    ],
    "accept-charset": [
      "UTF-8"
    ],
    "accept-encoding": [
      "br, deflate, gzip, x-gzip"
    ],
    "authorization": [
      "Bearer ..."
    ],
    "content-type": [
      "application/json"
    ],
    "host": [
      "my-dev-host.com"
    ]
  },
  "headers": {
    "accept": "application/json",
    "accept-charset": "UTF-8",
    "accept-encoding": "br, deflate, gzip, x-gzip",
    "authorization": "Bearer ...",
    "content-type": "application/json",
    "host": "my-dev-host.com"
  },
  "pathParameters": {},
  "httpMethod": "GET",
  "stageVariables": {},
  "path": "/fdx/v6/accounts",
  "isBase64Encoded": false,
  "requestSource": "ALB"
}

我尝试将请求修改为

GET https://my-dev-host.com/fdx/v6/accounts?accountIds=confUser_1&,confUser_2,confUser_3,confUser_4&offset=1&limit=3
Authorization: Bearer ....
Accept: application/json
Accept-Charset: UTF-8
Content-Type: application/json

但还是没有运气。

这是我的控制器的 API:

@RequestMapping(
        method = RequestMethod.GET,
        value = "/accounts",
        produces = {"application/json"}
)
ResponseEntity<Object> searchForAccounts(
        @Parameter(name = "accountIds", description = "Comma separated list of account ids", in = ParameterIn.QUERY) @Valid @RequestParam(value = "accountIds", required = false) List<String> accountIds,       
        @Parameter(name = "offset", description = "Opaque cursor used by the provider to send the next set of records", in = ParameterIn.QUERY) @Valid @RequestParam(value = "offset", required = false) String offset,
        @Parameter(name = "limit", description = "Number of elements that the consumer wishes to receive. Providers should implement reasonable default and maximum values", in = ParameterIn.QUERY) @Valid @RequestParam(value = "limit", required = false) Integer limit
);
amazon-web-services spring-boot aws-lambda
1个回答
0
投票

我相信 API 网关映射查询参数的方式需要用逗号分隔

accountIds
。又名
https://my-dev-host.com/fdx/v6/accounts?accountIds=confUser_1,confUser_2,confUser_3,confUser_4&offset=1&limit=3

© www.soinside.com 2019 - 2024. All rights reserved.