1

我在 API Gateway 中创建了一个基本的 GET url;带有一个名为“name”的路径参数。

如何访问此名称参数?我在任何事件或上下文中都看不到它。

我是否误会了参数路径的目的?

让我以我的游戏应用为例:

GET /api/v1/person                      @controllers.PersonController.list(limit: Int ?= 50, offset: Long ?= 0)
GET /api/v1/person/$id<[0-9]+>          @controllers.PersonController.getById(id: Long)
GET /api/v1/person/$id<[0-9]+>/email    @controllers.PersonController.getEmailByPersonId(id: Long)

这可以使用 AWS API Gateway 实现吗?

4

1 回答 1

1

根据文档,您应该可以使用映射模板执行此操作:http: //docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html

修改他们的示例(底部附近的“示例请求和响应”)以适合您的 URI,它看起来像这样

//Resource: /api/v1/person/{id}

//With input template(this is what your lambda will see in the event):
{
    "id" : "$input.params('id')"
    "person" : $input.json(‘$.person')
}

//POST /api/v1/person/{id}
{
    "person" : {
        "name": "bob"
    }
}
于 2015-11-06T00:34:09.820 回答