1、 After Route Predicate Factory
輸入一個(gè)參數(shù):時(shí)間想罕,匹配該時(shí)間之后的請(qǐng)求,示例配置:
spring:
cloud:
gateway:
routes:
- id: after_route
uri: https://anoyi.com
predicates:
- After=2019-11-11T11:11:11.111+08:00[Asia/Shanghai]
2、Before Route Predicate Factory
輸入一個(gè)參數(shù):時(shí)間换吧,匹配該時(shí)間之前的請(qǐng)求,示例配置:
spring:
cloud:
gateway:
routes:
- id: before_route
uri: https://anoyi.com
predicates:
- Before=2019-11-11T11:11:11.111+08:00[Asia/Shanghai]
3钥星、Between Route Predicate Factory
輸入兩個(gè)參數(shù):時(shí)間1、時(shí)間2满着,匹配該時(shí)間段的請(qǐng)求谦炒,示例配置:
spring:
cloud:
gateway:
routes:
- id: between_route
uri: https://anoyi.com
predicates:
- Between=2019-11-10T11:11:11.111+08:00[Asia/Shanghai], 2019-11-12T11:11:11.111+08:00[Asia/Shanghai]
4、Cookie Route Predicate Factory
輸入兩個(gè)參數(shù):Cookie 名稱风喇、正則表達(dá)式宁改,匹配 Cookie 中是否存在該名稱且值與正則表達(dá)式匹配,示例配置:
spring:
cloud:
gateway:
routes:
- id: cookie_route
uri: https://anoyi.com
predicates:
- Cookie=name, ano.i
5魂莫、Header Route Predicate Factory
輸入兩個(gè)參數(shù):Header 名稱还蹲、正則表達(dá)式,匹配 Header 中是否存在該名稱且值與正則表達(dá)式匹配耙考,示例配置:
spring:
cloud:
gateway:
routes:
- id: header_route
uri: https://anoyi.com
predicates:
- Header=name, ano.i
6谜喊、Host Route Predicate Factory
輸入一個(gè)參數(shù):Host Name 表達(dá)式列表,匹配 Header 中 Host 字段的值倦始,示例配置:
spring:
cloud:
gateway:
routes:
- id: host_route
uri: https://anoyi.com
predicates:
- Host=**.anoyi.cn,**.anoyi.io
7斗遏、Method Route Predicate Factory
輸入一個(gè)參數(shù):HTTP Method,匹配請(qǐng)求方法鞋邑,示例配置:
spring:
cloud:
gateway:
routes:
- id: method_route
uri: https://anoyi.com
predicates:
- Method=GET
8诵次、Path Route Predicate Factory
輸入兩個(gè)參數(shù):Spring PathMatcher
表達(dá)式列表、【可選】matchOptionalTrailingSeparator
標(biāo)識(shí)枚碗,示例配置:
spring:
cloud:
gateway:
routes:
- id: host_route
uri: https://anoyi.com
predicates:
- Path=/foo/{segment},/bar/{segment}
9逾一、Query Route Predicate Factory
輸入兩個(gè)參數(shù):請(qǐng)求參數(shù)、【可選】正則表達(dá)式肮雨,匹配請(qǐng)求地址類似于 https://anoyi.com/test?hello=world&name=anoyi
所包含的 request params遵堵, 示例配置:
# 僅匹配是否包含參數(shù) hello
spring:
cloud:
gateway:
routes:
- id: query_route
uri: https://anoyi.com
predicates:
- Query=hello
# 匹配參數(shù) name 是否以 ano 開(kāi)頭
spring:
cloud:
gateway:
routes:
- id: query_route
uri: https://anoyi.com
predicates:
- Query=name, ano.*
10、RemoteAddr Route Predicate Factory
輸入一個(gè)參數(shù):IPv4 或 IPv6 地址列表怨规,匹配請(qǐng)求來(lái)源的IP地址是否在該列表鄙早,示例配置:
spring:
cloud:
gateway:
routes:
- id: remoteaddr_route
uri: https://anoyi.com
predicates:
- RemoteAddr=192.168.1.1/24