Skip to content
Advertisement

Route order in Spring Cloud Gateway

We are implementing routes programmatically using a implementation of RouteDefinitionLocator. We have two services which should register at the same route path, where one of them is meant as a fallback if the other one does not exist. The preferred route with the specific path is:

JavaScript

And the more general one, which should only fire if other route was found:

JavaScript

Thus, when calling /yambas/rest/apps/bla/models/ms, the first route should be used, and when calling /yambas/rest/apps/bla/models/otherms/*, the second (fallback ) should be used.

Problem is, that even the order attribute at the route seems not to solve this; currently we find no possibility to set up this order / priority of routes. Is this intendet?

Advertisement

Answer

It seems that we set the order the wrong way – setting the lower priority route to order 1 and the higher to 0 makes it work.

@spencergibb that would be definitely worth to be mentioned in the documentation.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement