AWS API Gateway:如何将多个方法请求参数合并为一个集成请求参数 [英] AWS API Gateway: How to combine multiple Method Request params into a single Integration Request param

查看:129
本文介绍了AWS API Gateway:如何将多个方法请求参数合并为一个集成请求参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用API​​网关作为S3的代理.该存储区由一个由以下两部分组成的组合键设置键:[userId]-[documentId].

I'd like to use API Gateway as a proxy to S3. The bucket is keyed by a composite key made up of two parts like this: [userId]-[documentId].

UserId作为路径参数进入API网关,documentId作为请求参数进入,例如: [gateway-url]/user1?documentId = doc1

UserId comes to API Gateway as a path parameter, documentId comes in as a request parameter, for example: [gateway-url]/user1?documentId=doc1

如何将两者结合在一起,以使s3查找URL具有以下格式: https://[bucket-url]/user1-doc1 ?

How can I combine the two so that the s3 lookup URL has the following format: https://[bucket-url]/user1-doc1?

谢谢.

推荐答案

  1. 设置您的方法请求以接受路径参数{userid}和查询参数{docid}.
  2. 设置集成请求以接受 method.request.querystring.docid method.request.path.userid 作为URL路径参数.
  3. 最后,将集成端点URL设置为 https://您的URL/ {userid}-{docid}
  1. Setup your Method Request to accept the path param {userid} and query param {docid}.
  2. Setup your Integration Request to accept both method.request.querystring.docid and method.request.path.userid as URL path params.
  3. Finally, setup your integration endpoint URL as https://your-url/{userid}-{docid}.

为此而挥霍的片段如下-

A swagger snippet for this is as follows-

"paths": {
"/concat-params/{userid}": {
  "get": {
    "parameters": [
      {
        "name": "userid",
        "in": "path",
        "required": true,
        "type": "string"
      },
      {
        "name": "docid",
        "in": "query",
        "required": false,
        "type": "string"
      }
    ],
    "responses": {...},
    "x-amazon-apigateway-integration": {
      "responses": {...},
      "requestParameters": {
        "integration.request.path.userid":"method.request.path.userid",
    "integration.request.path.docid":"method.request.querystring.docid"
      },
      "uri": "https:.../{userid}-{docid}",
      ...
    }
  }
}

希望这会有所帮助,里蒂莎.

Hope this helps, Ritisha.

这篇关于AWS API Gateway:如何将多个方法请求参数合并为一个集成请求参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆