1 Predicates(断言)

spring:
  cloud:
    gateway:
      routes:
      - id: after_route
        uri: <https://example.org>
        # 满足断言条件才会转发到路由
        predicates:
        - Cookie=mycookie,mycookievalue
 # 完全展开参数
 spring:
  cloud:
    gateway:
      routes:
      - id: after_route
        uri: <https://example.org>
        predicates:
        - name: Cookie
          args:
            name: mycookie
            regexp: mycookievalue        
spring:
  cloud:
    gateway:
      routes:
      - id: after_route
        uri: <https://example.org>
        predicates:
        # 时间在这个时间之后的请求
        - After=2017-01-20T17:42:47.789-07:00[America/Denver]
        # 时间在这个时间之前的请求
        - Before=2017-01-20T17:42:47.789-07:00[America/Denver]
				# 时间在这俩时间之间的请求
				- Between=2017-01-20T17:42:47.789-07:00[America/Denver], 2017-01-21T17:42:47.789-07:00[America/Denver]
				# 携带下方cookie的请求
				- Cookie=chocolate, ch.p
				# 请求头包含当前head的请求
				- Header=X-Request-Id, \\d+
				# 
				- Host=**.somehost.org,**.anotherhost.org
				# 请求方法为get,post的请求
				- Method=GET,POST
				# 路径包含当前配置的请求
				- Path=/red/{segment},/blue/{segment}
				# 请求中包含查询参数green
				- Query=green
				# 包含一个 red 的查询参数,其值与 gree. 表达式相匹配
				- Query=red, gree.
				# 请求的远程地址匹配则路由过去
				- RemoteAddr=192.168.1.1/24
spring:
  cloud:
    gateway:
      routes:
      - id: weight_high
        uri: <https://weighthigh.org>
        predicates:
        # 配置权重80%
        - Weight=group1, 8
      - id: weight_low
        uri: <https://weightlow.org>
        predicates:
        # 配置权重20%
        - Weight=group1, 2
# 此路由将转发~80%的流量到 weighthigh.org,~20%的流量到 weighlow.org

2 过滤器

过滤器(Filter)允许以某种方式修改传入的 HTTP 请求或传出的 HTTP 响应。