1. Header Route Predicater(请求头校验)
predicates:
- name: Header
args:
header: my
regexp: bjsxt.*
请求头中包含my,并且符合bjsxt.*这个正则校验,才能通过gateway,否则返回404
2. Query Route Predicate(请求参数校验)
predicates:
- Query=name,admin.*
要有请求头参数名name并且值还要以admin开头才能路由,请求体不行
3. Method Route Predicate(请求方法校验)
predicates:
- Method=GET,POST
设置了之后只有GET和POST请求会路由
4. RemoteAddr Route Predicate(客户端IP校验)
predicates:
- RemoteAddr=192.168.1.1/24
设置了只有此IP发送的请求才能通过路由
5. Cookie Route Predicate(请求中的cookie校验)
predicates:
- Cookie=username,zzyy
设置了之后只有包含username的cookie,并且通过zzyy的正则校验才能路由
6. After/Between/Before Route Predicate(请求时间校验)
predicates:
- Between=2017-01-20T17:42:47.789-07:00[America/Denver], 2017-01-21T17:42:47.789-07:00[America/Denver]
对请求时间的校验
7. Path Route Predicate(路径匹配校验)
predicates:
- Path=/payment/lb/**
符合此路径的才能路由
8. Host Route Predicate(Host校验)
predicates:
- Host=**.baidu.com
只校验Header中的Host参数
正确:curl http://localhost:9527/payment/lb -H “Host: www.baidu.com”
正确:curl http://localhost:9527/payment/lb -H “Host: java.baidu.com”
错误:curl http://localhost:9527/payment/lb -H “Host: java.baidu.net”