Skip to content

Commit

Permalink
Update gateway-request-predicates.adoc (#3208)
Browse files Browse the repository at this point in the history
Update gateway-request-predicates.adoc
  • Loading branch information
Robinson28years authored Mar 8, 2024
1 parent 800cb5c commit 966a183
Showing 1 changed file with 82 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ The following example configures an after route predicate:
spring:
cloud:
gateway:
routes:
- id: after_route
uri: https://example.org
predicates:
- After=2017-01-20T17:42:47.789-07:00[America/Denver]
mvc:
routes:
- id: after_route
uri: https://example.org
predicates:
- After=2017-01-20T17:42:47.789-07:00[America/Denver]
----

.GatewaySampleApplication.java
Expand Down Expand Up @@ -61,11 +62,12 @@ The following example configures a before route predicate:
spring:
cloud:
gateway:
routes:
- id: before_route
uri: https://example.org
predicates:
- Before=2017-01-20T17:42:47.789-07:00[America/Denver]
mvc:
routes:
- id: before_route
uri: https://example.org
predicates:
- Before=2017-01-20T17:42:47.789-07:00[America/Denver]
----

.GatewaySampleApplication.java
Expand Down Expand Up @@ -105,11 +107,12 @@ The following example configures a between route predicate:
spring:
cloud:
gateway:
routes:
- id: between_route
uri: https://example.org
predicates:
- Between=2017-01-20T17:42:47.789-07:00[America/Denver], 2017-01-21T17:42:47.789-07:00[America/Denver]
mvc:
routes:
- id: between_route
uri: https://example.org
predicates:
- Between=2017-01-20T17:42:47.789-07:00[America/Denver], 2017-01-21T17:42:47.789-07:00[America/Denver]
----

.GatewaySampleApplication.java
Expand Down Expand Up @@ -148,11 +151,12 @@ The following example configures a cookie route predicate factory:
spring:
cloud:
gateway:
routes:
- id: cookie_route
uri: https://example.org
predicates:
- Cookie=chocolate, ch.p
mvc:
routes:
- id: cookie_route
uri: https://example.org
predicates:
- Cookie=chocolate, ch.p
----

.GatewaySampleApplication.java
Expand Down Expand Up @@ -189,11 +193,12 @@ The following example configures a header route predicate:
spring:
cloud:
gateway:
routes:
- id: header_route
uri: https://example.org
predicates:
- Header=X-Request-Id, \d+
mvc:
routes:
- id: header_route
uri: https://example.org
predicates:
- Header=X-Request-Id, \d+
----

.GatewaySampleApplication.java
Expand Down Expand Up @@ -231,11 +236,12 @@ The following example configures a host route predicate:
spring:
cloud:
gateway:
routes:
- id: host_route
uri: https://example.org
predicates:
- Host=**.somehost.org,**.anotherhost.org
mvc:
routes:
- id: host_route
uri: https://example.org
predicates:
- Host=**.somehost.org,**.anotherhost.org
----

.GatewaySampleApplication.java
Expand Down Expand Up @@ -278,11 +284,12 @@ The following example configures a method route predicate:
spring:
cloud:
gateway:
routes:
- id: method_route
uri: https://example.org
predicates:
- Method=GET,POST
mvc:
routes:
- id: method_route
uri: https://example.org
predicates:
- Method=GET,POST
----

.GatewaySampleApplication.java
Expand Down Expand Up @@ -345,11 +352,12 @@ The following example configures a path route predicate:
spring:
cloud:
gateway:
routes:
- id: path_route
uri: https://example.org
predicates:
- Path=/red/{segment},/blue/{segment}
mvc:
routes:
- id: path_route
uri: https://example.org
predicates:
- Path=/red/{segment},/blue/{segment}
----

.GatewaySampleApplication.java
Expand Down Expand Up @@ -402,11 +410,12 @@ The following example configures a query route predicate:
spring:
cloud:
gateway:
routes:
- id: query_route
uri: https://example.org
predicates:
- Query=green
mvc:
routes:
- id: query_route
uri: https://example.org
predicates:
- Query=green
----

.GatewaySampleApplication.java
Expand Down Expand Up @@ -437,11 +446,12 @@ The preceding route matches if the request contained a `green` query parameter.
spring:
cloud:
gateway:
routes:
- id: query_route
uri: https://example.org
predicates:
- Query=red, gree.
mvc:
routes:
- id: query_route
uri: https://example.org
predicates:
- Query=red, gree.
----

.GatewaySampleApplication.java
Expand Down Expand Up @@ -480,11 +490,12 @@ The following example configures a RemoteAddr route predicate:
spring:
cloud:
gateway:
routes:
- id: remoteaddr_route
uri: https://example.org
predicates:
- RemoteAddr=192.168.1.1/24
mvc:
routes:
- id: remoteaddr_route
uri: https://example.org
predicates:
- RemoteAddr=192.168.1.1/24
----
This route matches if the remote address of the request was, for example, `192.168.1.10`.
Expand Down Expand Up @@ -559,15 +570,16 @@ The following example configures a weight route predicate:
spring:
cloud:
gateway:
routes:
- id: weight_high
uri: https://weighthigh.org
predicates:
- Weight=group1, 8
- id: weight_low
uri: https://weightlow.org
predicates:
- Weight=group1, 2
mvc:
routes:
- id: weight_high
uri: https://weighthigh.org
predicates:
- Weight=group1, 8
- id: weight_low
uri: https://weightlow.org
predicates:
- Weight=group1, 2
----

.GatewaySampleApplication.java
Expand Down Expand Up @@ -617,11 +629,12 @@ The following example configures a XForwardedRemoteAddr route predicate:
spring:
cloud:
gateway:
routes:
- id: xforwarded_remoteaddr_route
uri: https://example.org
predicates:
- XForwardedRemoteAddr=192.168.1.1/24
mvc:
routes:
- id: xforwarded_remoteaddr_route
uri: https://example.org
predicates:
- XForwardedRemoteAddr=192.168.1.1/24
----
This route matches if the `X-Forwarded-For` header contains, for example, `192.168.1.10`.
Expand Down

0 comments on commit 966a183

Please sign in to comment.