我在 API Gateway 中创建了一个基本的 GET url;带有名为“name”的路径参数。
如何访问此名称参数?我在任何事件或上下文中都没有看到它。
我是否误解了参数路径的目的?
让我使用我的 Play 应用程序为例:
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 实现吗?
最佳答案
根据文档,您应该能够使用映射模板来执行此操作: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"
}
}
关于node.js - 如何访问AWS API Gateway的路径参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33555279/