Official website: Spring Cloud Gateway
Name | Description | Example |
After | is a request after a certain point in time | – After=2023-08-20T17:42:47.789-07:00 [America/Denver] |
Before | is a request before a certain point in time | – Before=2031-04-13T15:14:47.433 + 08:00[Asia/Shanghai] |
Between | is a request before two time points | – Between=2037-01-20T17:42:47.789-07:00[ America/Denver], 2037-01-21T17:42:47.789-07:00[America/Denver] |
Cookie | The request must contain certain cookies | – Cookie=chocolate, ch.p |
Header | The request must contain certain headers | – Header=X-Request-Id, \d + |
Host | The request must be to visit a host (domain name) | Host=**.somehost.org,**.anotherhost.org |
Method | The request method must be specified Method | – Method=GET,POST |
Path | The request path must conform to the specified rules | – Path=/red/{segment},/blue/** |
Query | Request parameters must contain specified parameters | – Query=name, Jack or- Query=name |
RemoteAddr | The requester’s ip must be in the specified range | – RemoteAddr=192.168.1.1/24 |
Weight | weight | – Weight=group1, 8 – Weight=group1, 2 |
1. The After Route Predicate Factory
spring: cloud: gateway: routes: - id: consumer uri: lb://consumer-service predicates: - After=2023-07-10T17:42:47.789-07:00
?
2. The Before Route Predicate Factory
spring: cloud: gateway: routes: - id: consumer uri: lb://consumer-service predicates: - Before=2023-10-20T17:42:47.789-07:00
3. The Between Route Predicate Factory
spring: cloud: gateway: routes: - id: consumer uri: lb://consumer-service predicates: - Between=2020-01-20T17:42:47.789-07:00, 2024-01-21T17:42:47.789-07:00
4. The Cookie Route Predicate Factory
cloud: gateway: routes: - id: consumer uri: lb://consumer-service predicates: -Cookie=chocolate, hello
5. The Header Route Predicate Factory
cloud: gateway: routes: - id: consumer uri: lb://consumer-service predicates: - Header=X-Request-Id, \d +
6. The Host Route Predicate Factory
spring: cloud: gateway: routes: - id: consumer uri: lb://consumer-service predicates: - Host=www.**.**
7. The Method Route Predicate Factory
spring: cloud: gateway: routes: - id: consumer uri: lb://consumer-service predicates: -Method=GET
8. The Path Route Predicate Factory
spring: cloud: gateway: routes: - id: consumer uri: lb://consumer-service predicates: -Path=/consumer/** filters: - StripPrefix=1
9. The Query Route Predicate Factory
spring: cloud: gateway: routes: - id: consumer uri: lb://consumer-service predicates: -Path=/consumer/** filters: - Query=green
10. The RemoteAddr Route Predicate Factory
spring: cloud: gateway: routes: - id: consumer uri: lb://consumer-service predicates: - RemoteAddr=192.168.200.1/24
11. The Weight Route Predicate Factory
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