Spring 云网关和 Consul 服务器
Spring cloud Gateway and Consul Server
请帮忙。
我有 Spring 云网关和领事服务器。在 Spring 云网关中,我使用 "cloud:gateway:discovery:locator:enabled:true"。我可以发送在 Consul 中注册的服务请求 (ServiceName)。例如 URL“/ServiceName/foo/bar”。
我可以自定义 Spring Cloud Gateway 以便查询看起来像 /foo/ bar/ServiceName/baz 吗?
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}'"
我的 application.yml
版本
spring:
cloud:
gateway:
locator:
enabled: true
predicates:
- name: Path
args:
pattern: "'/foo/bar/' + serviceId + '/**'"
filters:
- name: RewritePath
args:
regexp: "'/foo/bar/' + serviceId + '/(?<remaining>.*)'"
replacement: "'/foo/bar/' + serviceId + '/${remaining}'"
请帮忙。 我有 Spring 云网关和领事服务器。在 Spring 云网关中,我使用 "cloud:gateway:discovery:locator:enabled:true"。我可以发送在 Consul 中注册的服务请求 (ServiceName)。例如 URL“/ServiceName/foo/bar”。 我可以自定义 Spring Cloud Gateway 以便查询看起来像 /foo/ bar/ServiceName/baz 吗?
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}'"
我的 application.yml
版本spring:
cloud:
gateway:
locator:
enabled: true
predicates:
- name: Path
args:
pattern: "'/foo/bar/' + serviceId + '/**'"
filters:
- name: RewritePath
args:
regexp: "'/foo/bar/' + serviceId + '/(?<remaining>.*)'"
replacement: "'/foo/bar/' + serviceId + '/${remaining}'"