The user wants to expose Rest APIs with path variables as mentioned in Rest API best practices; using an URI like "/articles/:articleId/comments". and then wants to retrieve the "articleId" in a context variable in APIGW.
APIGW allows URIs like "/articles/*" and we able to parse the postfix in APIGW but this requires manual implementations in the API.
As most of the Rest API frameworks (like spring) implement that feature; could you provide a solution to get that behavior without manual coding in APIGW?
API Gateway 10.x
${request.url} would return the entire string, ${request.url.path} would return /articles/:articleId/comments, from here you could use an regular expression assertion to obtain the section required.
You can get parameters via:-
${request.http.parameter.<name>}
but this is for items after the a question mark in a url.
Another method:
You can also split this using the split variable assertion, plotting on / (the slash) it then create a new variable and you can access the parts of the URI in the parts.
for example if the split variable sets a var called URIparts then /articles/:articleId/comments would return :
${URIparts[1]} = articles
${URIparts[2]} = articleid
${URIparts[3]} = comments
there would be a ${URIparts[0]} but in our case that would be empty as its the part before the first /