2015-11-05 113 views
1

我在API网关中创建了一个基本的GET url;带有一个名为“name”的路径参数。如何访问AWS API网关的路径参数?

如何访问此名称参数?我没有看到它在任何事件或背景下。

我误解了参数路径的用途吗?

让我用我的游戏应用程序,例如:

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网关?

回答

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" 
    } 
} 
+0

猜想我需要阅读一些文档!谢谢 – iCodeLikeImDrunk

相关问题