5

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?

2 Answers 2

5

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.

Sign up to request clarification or add additional context in comments.

2 Comments

do you have any documentation for this? I'm trying to test your suggestion, and I'm getting an error indicative of it not respecting the greedy path variables: missing authentication token
Running locally with serverless-offline doesn't work right; it's URL-encoding the slashes
3

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.