Skip to content

Commit 54f6d19

Browse files
authored
1 parent 8be99a3 commit 54f6d19

File tree

1 file changed

+30
-28
lines changed

1 file changed

+30
-28
lines changed

docs/modules/ROOT/pages/spring-cloud-gateway-server-webflux/the-discoveryclient-route-definition-locator.adoc

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ You can configure the gateway to create routes based on services registered with
55

66
By default, the routes created use the protocol `lb://service-name` (where `service-name` is the String that `DiscoveryClient::getServices` will return) and this means that they are load-balanced. For that reason, you also need to include the `org.springframework.cloud:spring-cloud-starter-loadbalancer` dependency, so that it is available on the classpath.
77

8-
To enable this, set `spring.cloud.gateway.discovery.locator.enabled=true` and make sure a `DiscoveryClient` implementation (such as Netflix Eureka, Consul, Zookeeper or Kubernetes) is on the classpath and enabled.
8+
To enable this, set `spring.cloud.gateway.server.webflux.discovery.locator.enabled=true` and make sure a `DiscoveryClient` implementation (such as Netflix Eureka, Consul, Zookeeper or Kubernetes) is on the classpath and enabled.
99

1010
[[configuring-predicates-and-filters-for-discoveryclient-routes]]
1111
== Configuring Predicates and Filters For `DiscoveryClient` Routes
@@ -18,23 +18,23 @@ the ID of the service from the `DiscoveryClient`.
1818
The default filter is a rewrite path filter with the regex `/serviceId/?(?<remaining>.*)` and the replacement `/$\{remaining}`.
1919
This strips the service ID from the path before the request is sent downstream.
2020

21-
If you want to customize the predicates or filters used by the `DiscoveryClient` routes, set `spring.cloud.gateway.discovery.locator.predicates[x]` and `spring.cloud.gateway.discovery.locator.filters[y]`.
21+
If you want to customize the predicates or filters used by the `DiscoveryClient` routes, set `spring.cloud.gateway.server.webflux.discovery.locator.predicates[x]` and `spring.cloud.gateway.server.webflux.discovery.locator.filters[y]`.
2222
When doing so, you need to make sure to include the default predicate and filter shown earlier, if you want to retain that functionality.
2323
The following examples shows what this looks like in properties and yaml format:
2424

2525
.application.properties
2626
[soure,properties]
2727
====
2828
----
29-
spring.cloud.gateway.discovery.locator.predicates[0].name=Path
30-
spring.cloud.gateway.discovery.locator.predicates[0].args[pattern]="'/'+serviceId+'/**'"
31-
spring.cloud.gateway.discovery.locator.predicates[1].name=Host
32-
spring.cloud.gateway.discovery.locator.predicates[1].args[pattern]="'**.foo.com'"
33-
spring.cloud.gateway.discovery.locator.filters[0].name=CircuitBreaker
34-
spring.cloud.gateway.discovery.locator.filters[0].args[name]=serviceId
35-
spring.cloud.gateway.discovery.locator.filters[1].name=RewritePath
36-
spring.cloud.gateway.discovery.locator.filters[1].args[regexp]="'/' + serviceId + '/?(?<remaining>.*)'"
37-
spring.cloud.gateway.discovery.locator.filters[1].args[replacement]="'/$\{remaining}'"
29+
spring.cloud.gateway.server.webflux.discovery.locator.predicates[0].name=Path
30+
spring.cloud.gateway.server.webflux.discovery.locator.predicates[0].args[pattern]="'/'+serviceId+'/**'"
31+
spring.cloud.gateway.server.webflux.discovery.locator.predicates[1].name=Host
32+
spring.cloud.gateway.server.webflux.discovery.locator.predicates[1].args[pattern]="'**.foo.com'"
33+
spring.cloud.gateway.server.webflux.discovery.locator.filters[0].name=CircuitBreaker
34+
spring.cloud.gateway.server.webflux.discovery.locator.filters[0].args[name]=serviceId
35+
spring.cloud.gateway.server.webflux.discovery.locator.filters[1].name=RewritePath
36+
spring.cloud.gateway.server.webflux.discovery.locator.filters[1].args[regexp]="'/' + serviceId + '/?(?<remaining>.*)'"
37+
spring.cloud.gateway.server.webflux.discovery.locator.filters[1].args[replacement]="'/$\{remaining}'"
3838
----
3939
====
4040

@@ -45,22 +45,24 @@ spring.cloud.gateway.discovery.locator.filters[1].args[replacement]="'/$\{remain
4545
spring:
4646
cloud:
4747
gateway:
48-
discovery:
49-
locator:
50-
predicates:
51-
- name: Host
52-
args:
53-
pattern: "'**.foo.com'"
54-
- name: Path
55-
args:
56-
pattern: "'/'+serviceId+'/**'"
57-
filters:
58-
- name: CircuitBreaker
59-
args:
60-
name: serviceId
61-
- name: RewritePath
62-
args:
63-
regexp: "'/' + serviceId + '/?(?<remaining>.*)'"
64-
replacement: "'/${remaining}'"
48+
server:
49+
webflux:
50+
discovery:
51+
locator:
52+
predicates:
53+
- name: Host
54+
args:
55+
pattern: "'**.foo.com'"
56+
- name: Path
57+
args:
58+
pattern: "'/'+serviceId+'/**'"
59+
filters:
60+
- name: CircuitBreaker
61+
args:
62+
name: serviceId
63+
- name: RewritePath
64+
args:
65+
regexp: "'/' + serviceId + '/?(?<remaining>.*)'"
66+
replacement: "'/${remaining}'"
6567
----
6668
====

0 commit comments

Comments
 (0)