I am trying to configure an API call router using zuul that forwards calls .
There are two services: the users service is using path versioning, i.e. /v1/users
, /v2/users
, ...
The accounts service does not use path versioning, thus all routes omit the v*
prefix (/accounts
).
To provide a common interface, I'd like to accept calls to /v*/accounts
in my api router and forward them to /accounts
on my accounts service.
Calls to /v*/user/
should be forwarded to the users service as they are.
My application.yml looks something like this
zuul:
routes:
users:
path: /v*/users/**
url: ${microservices.usersServiceUrl}
stripPrefix: false
accounts:
path: /v*/accounts/**
url: ${microservices.accountsServiceUrl}
stripPrefix: true
This does not have the intended effect, unfortunately. Nothing from the account paths in stripped and they are forwarded as they are.
If I remove the regex (v*
) and put path: /v1/accounts/**
instead, the entire prefix /v1/accounts
is stripped off. Apparently a regex prevents the prefix being stripped off, thus putting path: /v1/**/accounts/**
works. However, I would like to avoid naming all versions explicitly as our API is evolving quite rapidly at the moment.
Using the global zuul.prefix
did not help either, as you can only globally decide to strip it off or leave it intact AFAIK.
I mostly relied on this documentation.
Is there a better way to specify the format of the forwarded URL?