Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

API Gateway variable number of path parameters

Is it possible to have a variable number of path parameters on an API gateway URL?

i.e. APIGW runs theoretical lambda function that sums numbers in a URL:

/dev/myservice/sum/1/2 => sum(1,2) => 3
/dev/myservice/sum/1/2/3/3/3 => sum(1,2,3,3,3) => 12

If this is possible, then how do I do it?

like image 640
Kristian Avatar asked Feb 13 '17 06:02

Kristian


2 Answers

You can use greedy path variables like /myservice/sum/{proxy+} and the lambda proxy integration (used by the serveless framework) to solve this use case.

like image 171
hellomichibye Avatar answered Sep 17 '22 13:09

hellomichibye


You can use the standard API Gateway proxy features, no need to use the serverless framework (although the framework is great for other reasons).

In the console it's pretty easy, this guide should take you through the setup. http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-create-api-as-simple-proxy-for-lambda.html

like image 25
jackko Avatar answered Sep 19 '22 13:09

jackko