Extract Matched params in the URL

#1

Hi,

Is there a way to extract parameters in the request URL and use them on the request transformer etc.

Example a GET on

http://localhost:8000/myAPIs/todos/1/user/nick

And 1 and nick are matched parameters.How can we access these?

Thanks.

#2

@saravana Hi,

Please have a look at the documentation:

In particular, the section on “capturing groups” in regex URL paths.

Also have a look at this post detailing regex URL paths in details, including capturing groups:

As of Kong 1.1, you’ll have to write a custom plugin to inject the captured group in some upstream request property (URL, header, etc…) via the ngx.ctx.router_matches table.

Starting with Kong 1.2 (about to be released at the end of May 2019), we will open source the request-transformer-advanced plugin (currently Enterprise only). This improved transformation plugin allows you to interpolate variables in upstream request properties, all without having to write the Lua logic yourself, only an HTTP request to the Admin API to configure the plugin. See this section of this plugin’s documentation.

Best,

#3

Thanks mate.Let me explore this further.