Search code examples
javaspringspring-cloudnetflix-zuulapi-gateway

Zuul routes priority higher than Spring Controllers


I have controller in my api gateway service:

@GetMapping("/test")

And I have the same endpoint in one of my routes.

When I call /test, my request get routed, how can I increase priority of Spring Controllers over zuul routing?


Solution

  • You could use add a route to your controller using forward in front of your path, for example:

     zuul:
      routes:
        controller:
          path: /test
          url: forward:/test
        other:
          ...
    

    and place it before your other route definition, in case of YAML file it will preserve an order.

    http://cloud.spring.io/spring-cloud-netflix/single/spring-cloud-netflix.html#_strangulation_patterns_and_local_forwards

    I haven't tested above example, but I use a similar solution and it works fine.