Spring Cloud Greenwich puts spring-cloud-netflix-zuul in maintenance mode, so I am trying to migrate from Zuul to Spring Cloud Gateway.
With Zuul I have a route like
zuul:
routes:
masterplan_match:
path: /**/masterplans/**
serviceId: api-masterplan
What I am doing there is basically ignoring everything that comes before or after masterplan in the received path and redirect to api-masterplan. For example, both /some/path/to/masterplans and /masterplans goes to the same api (the reason being masterplans are a subresource of a bigger entity, which is responsible for creating new masterplans, but then masterplans can be treated as full blown resources for purposes like GETting details, updating, deleting).
Can I map this configuration to Spring Cloud Gateway? Looking at predicates, the feasible one seems to be path predicate, but then it looks like all matchers work on individual path elements (except the WildcardTheRestPathElement, which however can be used only as last element - I think), ie: I would need to write something like
spring
cloud:
gateway:
routes:
- id: masterplan_match
uri: lb://api-masterplan # Coming from discovery client
predicates:
- Path=/some/path/to/masterplans/**, /masterplans/**
Am I missing something and can the two paths be condensed in one?
Spring Cloud Gateway support multiple patterns since version 2.1.0
spring
cloud:
gateway:
routes:
- id: masterplan_match
uri: lb://api-masterplan # Coming from discovery client
predicates:
- Path=/some/path/to/masterplans/**, /masterplans/**
See Also:
Add support for multiple paths in path predicate #256
Multiple patterns in Host Route Predicate #589
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With