Include version before listen_path

Hi, is there any way to add the version automatically before the listen_path ?

Let’s say I have an API with a listen_path identifying a project, so my listen_path is a project ID like this 38bb66741644bb4ac74a76e8a95095c. If I add the version the url will be:

https://api.example.io/d38bb66741644bb4ac74a76e8a95095c/v1/

But I want it to be:
https://api.example.io/v1/d38bb66741644bb4ac74a76e8a95095c/

Is there any way to do that?

By default, versioning does not support this. But you could hack a scenario where API A with listen path “/d38bb66741644bb4ac74a76e8a95095c” and no version will Url Rewrite the path to an API B with listen path “/” that has versioning enabled on it. You might have to hardcode API A’s listen path in the url rewrite

Using a custom plugin might be another option because you can achieve almost anything with it. However, let me ask a few folks internally.

I asked internally and there are several ways to achieve this. One of them is what I have suggested, however, how does the version play into the customer IDs as mentioned here in the scenario? I assume the version is or will be dynamic. Also is there a version at the backend?

Hi @Olu and thanks for your answer.

The idea is to have something like this:

http://api.example.com/v1/customerid01
http://api.example.com/v1/customerid02
http://api.example.com/v1/customeriN

And then if we have a second version

http://api.example.com/v2/customerid01
http://api.example.com/v2/customerid02
http://api.example.com/v2/customeriN

If that is the case, then what I earlier suggested should work just fine. There is the caveat of latency and load balancing the calls if they are much, but it would work.

Note: Setting an empty(/) listen path would disable gateway health checks