Routes configuration asserts predicates multiple paths
1. Directly upload the code: Note that the most important thing is that only versions above 2.1.0 allow multiple Path=/test/t1,/testw/t2,y paths separated by commas! ! ! important
routes: #!!!一个请求满足多个路由的谓词条件时,请求只会被首个成功匹配的路由转发
- id: eurake-client #服务的ID唯一最好和要跳转的服务有关联
uri: lb://eureka-client-article-service #跳转的目标访问地址
predicates:
- Path=/test/batis/test,/test/testJmeter,
- Method=GET,POST
- Before=2021-05-09T09:11:27.551+08:00[Asia/Shanghai] #3.在某个时间点之前--》》可以匹配访问ZonedDateTime格式
- After=2021-04-09T09:11:27.551+08:00[Asia/Shanghai] #4.在某个时间点之后--》》可以匹配访问
- Between=2021-04-09T09:11:27.551+08:00[Asia/Shanghai],2021-05-09T09:11:27.551+08:00[Asia/Shanghai] #5.同上,时间点之间
- Header=X-Header-Token,token #6.根据header中的信息匹配--》》提供两个值name,value(正则)两个值必须均匹配
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
<version>2.2.5.RELEASE</version>
</dependency>
Here is the source code basis, please see
Note: It can be clearly seen that the change from String to List