Reputation: 17866
I created a basic GET url in API Gateway; with a path parameter called "name".
How can I access this name param? I don't see it in neither event or context.
Am I mistaken at the purpose of the parameter path?
Let me use my play app for example:
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)
Is this achievable using AWS API Gateway?
Upvotes: 2
Views: 9474
Reputation: 5983
According to the docs you should be able to do this with a mapping template: http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html
Modifying their example("Example Request and Response" near the bottom) to fit your URI it would look like this
//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"
}
}
Upvotes: 3