-
Between表示路由在指定时间段之内才生效,既然是时间段就是两个参数,注意它们的写法
-
配置文件:
spring:
application:
name: hello-gateway
cloud:
gateway:
routes:
- id: between_route
uri: http://127.0.0.1:8082
predicates:
- Between=2021-08-16T07:36:00.000+08:00[Asia/Shanghai], 2021-08-16T08:15:00.000+08:00[Asia/Shanghai]
- 动态路由的JSON格式,注意args参数,起始时间是datetime1,结束时间是datetime2:
[
{
“id”: “path_route_addr”,
“uri”: “http://127.0.0.1:8082”,
“predicates”:[
{
“name”: “Between”,
“args”: {
“datetime1”: “2021-08-16T07:36:00.000+08:00[Asia/Shanghai]”,
“datetime2”: “2021-08-16T08:18:00.000+08:00[Asia/Shanghai]”
}
}
]
}
]
Cookie
-
Cookie表示cookie存在指定名称,并且对应的值符合指定正则表达式,才算匹配成功
-
配置文件:
spring:
cloud:
gateway:
routes:
- id: cookie_route
uri: https://example.org
predicates:
- Cookie=chocolate, ch.p
- 动态路由的JSON格式,注意args参数:
[
{
“id”: “cookie_route”,
“uri”: “http://127.0.0.1:8082”,
“predicates”:[
{
“name”: “Cookie”,
“args”: {
“name”: “chocolate”,
“regexp”: “ch.p”
}
}
]
}
]
Header
-
Header表示header存在指