I have a url path that looks like this:
/{identifier}/rest/of/resource/path
If the identifier
is A
then the request should go to service_I
. If the identifier
is B
then the request should also go to service_I
. If the identifier
is C
, then the request should go to service_II
, and so on.
Later on a new identifiers
M
and N
is added to the system and their requests should be routed to service_IV
.
Is it possible to dynamically configure a Spring cloud zuul proxy to perform the tasks described above?
Edit
This question offered contains a different way to examine the question.
In it Zuul has the following configuration:
zuul:
routes:
<service_id>:
path: /path/**
Zuul will collaborate with Eureka to find the service-id
and return the host parameters so that the service can be accessed. What if instead of /path
we have /{userID}
and the userID
instances are distributed across several service_id
hosts?
Can Zuul / the DiscoveryClient query Eureka for both the service_id
and the userID
to figure out which host is hosting the particular userID
?
You would need to write a custom
ZuulFilter
to accomplish this. Take a look at the PreDecorationFilter for some hints as this is the filter responsible for handling/path
where the path is aservice-id
(among other things).