本笔记内容为尚硅谷SpringCloud框架开发Gateway的Predicate的使用部分
目录
1. After Route Predicate
多少时间之后访问
我们的问题是:上述这个After好懂,这个时间串串怎么获取
package com.atguigu.test;
import java.time.ZoneId;
import java.time.ZonedDateTime;
public class ZonedDateTimeDemo
{
public static void main(String[] args)
{
ZonedDateTime zbj = ZonedDateTime.now(); // 默认时区
System.out.println(zbj);
// ZonedDateTime zny = ZonedDateTime.now(ZoneId.of("America/New_York")); // 用指定时区获取当前时间
// System.out.println(zny);
}
}
2. Before Route Predicate
多少时间之前访问
3. Between Route Predicate
多少时间到多少时间内之间访问
4. Cookie Route Predicate
不带cookies访问
带上cookies访问
5. Header Route Predicate
两个参数:一个是属性名称和一个正则表达式,这个属性值和正则表达式匹配则执行
6. Host Route Predicate
请求域名格式
Host Route Predicate 接收一组参数,一组匹配的域名列表,这个模板是一个 ant 分隔的模板,用.号作为分隔符。它通过参数中的主机地址作为匹配规则。
7. Method Route Predicate
请求的方式
8. Path Route Predicate
请求路径格式
9. Query Route Predicate
请求的参数和格式
支持传入两个参数,一个是属性名,一个为属性值,属性值可以是正则表达式。
Predicate就是为了实现一组匹配规则,让请求过来找到对应的Route进行处理。
结束!