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:
i am also trying to do what [milind1] is trying to do. Specifially I: am trying to define this in a declarative config file. But my problem is I am not sure what syntax would need to be setup in order for my parameters to be added to do upstream server request.
Here is what I current have in my kong file
format_version: "1.1"
services:
- name: find_test_id
url: http://address:8080/rest/app/ \\i am assuming that the plugin will add the test id to this url
routes:
- name: find_test_id
paths:
- /find_test_id/id:(?<id>\d+) \\is this correct?
plugins:
- name: request-transformer
route: find_test_id
content-type:application/json
config:
add:
body:["id"]
When I try to send a request to https://localhost:8443/find_test_id/id:20 , the upstream rqt does not add the id value to the end of the url and therefore returns a 500 error.
{“message”:“An unexpected error occurred”}
Any input on this issue will greatly be appreciated.