0

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?

Community
  • 1
  • 1
Ole
  • 41,793
  • 59
  • 191
  • 359
  • 1
    Are you using Spring Cloud Config server? Have you tried changing the config for Zuul and then calling the `/refresh` endpoint? – Ryan Baxter Jan 05 '17 at 12:16
  • I'll try experimenting with that. Not sure whether Zuul supports many to one mappings - many identifiers to single server ... – Ole Jan 05 '17 at 19:22
  • Eureka does not currently have any facility for mapping serviceid and a query parameter to find a service host. You would need to write a custom zuul filter. – spencergibb Jan 09 '17 at 19:20
  • @spencergibb In my case I think the serviceid is probably redundant because the {identifier} parameter is globally unique, hence it should be sufficient for identification of the host(s) containing it. Do you think the Zuul filter is still the right route? I'm basically just replacing the serviceID with the {identifier}, which will most likely be a UUID string. – Ole Jan 11 '17 at 00:58
  • Yes, you would need to write a filter – spencergibb Jan 11 '17 at 02:24

1 Answers1

1

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 a service-id (among other things).

dustin.schultz
  • 13,076
  • 7
  • 54
  • 63