spring-cloud-netflix icon indicating copy to clipboard operation
spring-cloud-netflix copied to clipboard

Zuul , exclude service name from being exposed

Open hodeh opened this issue 9 years ago • 3 comments

I am using Zuul to expose all of the micro-services registered in eureka as is.

I want to avoid manually declaring and configuring routes for each service URL whenever I am adding a service, so all eureka registered services will be exposed according to the routes defined by each service.

Without declaring/configuring any Zuul route; that has given what I need except for one more requirement; I dont want the service name (spring.application.name) to be exposed through the public API gateway for the service.

so instead of exposing: http://{zuul.service.hostname}/{zuul.port}/{zuul.prefix}/service-a/v1.0/rest-resource-by-a it should be exposed as: http://{zuul.service.hostname}/{zuul.port}/{zuul.prefix}/v1.0/resource-defined-by-a (service-a part is removed)

I am thinking of overriding DiscoveryClientRouteLocator and then building routes on Zuul startup from each discoverable service by inquiring all exposed Request Mappings exposed by that service, I will somehow guarantee that the underlying services wont have any request-mapping conflicts. Do you think that makes any sense and I should go this way? or is there something more feasible ?

hodeh avatar Jun 12 '17 07:06 hodeh

I dont have a better suggestion at the moment. Providing your own DiscoveryClientRouteLocator bean should work.

ryanjbaxter avatar Jun 12 '17 15:06 ryanjbaxter

Most folks just use configuration and turn off the integration

spencergibb avatar Jun 12 '17 15:06 spencergibb

alright @ryanjbaxter @spencergibb I will post the custom DiscoveryClientRouteLocator here if I managed to do it thanks.

hodeh avatar Jun 12 '17 16:06 hodeh