Please help. I have Spring Cloud Gateway and Consul Server. In Spring Cloud Gateway i'm use "cloud:gateway:discovery:locator:enabled:true". I can send requests for services registered in the Consul (ServiceName). For example URL "/ServiceName/foo/bar". Can I customize Spring Cloud Gateway so that the queries would look like /foo/ bar/ServiceName/baz ?
Yes you can
spring.cloud.gateway.discovery.locator.predicates[0].name: Path
spring.cloud.gateway.discovery.locator.predicates[0].args[pattern]: "'/foo/bar/'+serviceId+'/**'"
spring.cloud.gateway.discovery.locator.filters[0].name: RewritePath
spring.cloud.gateway.discovery.locator.filters[0].args[regexp]: "'/' + serviceId + '/foo/bar/(?<remaining>.*)'"
spring.cloud.gateway.discovery.locator.filters[0].args[replacement]: "'/${remaining}'"