Kong : parameter support in url

#1

I’m trying to create api which has parameters in its url.

API:
http://example.com/lead/{latitude}/{longitude}
http://example.com/lead/{tile}/road

Is it supported in kong? If yes then please point to any documentation. If no then is there any other workaround.

Note: Also I’m just getting started with kong. Please point me to any tutorials, blogs, courses, etc.

#2

Hi, and welcome!

The best resource on this topic if you are just getting started is the Proxy Guide:

Long story short, Kong doesn’t have to know about the dynamic segments in your URL path component. Specifying a prefix (e.g. /lead) will work just fine. Most likely, your API will return HTTP 404 in the event than a request hits a non-existing path (e.g. /lead/foo).

If you’d rather enforce that Kong can only proxy those two paths, then a regex path is your goto choice (also documented in the above resource). You can leverage regex capture groups to extract the value of those path segments. Have a look at this post for an in-depth dive into regex paths and capture groups:

1 Like