Home:ALL Converter>Spring cloud Gateway and Consul Server

Spring cloud Gateway and Consul Server

Ask Time:2019-01-31T20:16:33         Author:Иван

Json Formatter

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 ?

Author:Иван,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/54460410/spring-cloud-gateway-and-consul-server
spencergibb :

Yes you can\n\nspring.cloud.gateway.discovery.locator.predicates[0].name: Path\nspring.cloud.gateway.discovery.locator.predicates[0].args[pattern]: \"'/foo/bar/'+serviceId+'/**'\"\nspring.cloud.gateway.discovery.locator.filters[0].name: RewritePath\nspring.cloud.gateway.discovery.locator.filters[0].args[regexp]: \"'/' + serviceId + '/foo/bar/(?<remaining>.*)'\"\nspring.cloud.gateway.discovery.locator.filters[0].args[replacement]: \"'/${remaining}'\"\n",
2019-01-31T16:39:01
yy