gateway 断言配置

After

判断在​​After​​配置的时间之后,路由配置才生效

spring:
  cloud:
    gateway:
      routes:
      - id: after_route
        uri: https://example.org
        predicates:
        - After=2017-01-20T17:42:47.789-07:00[America/Denver]

Before

判断在​​Before​​之前,路由配置才生效

spring:
  cloud:
    gateway:
      routes:
      - id: before_route
        uri: https://example.org
        predicates:
        - Before=2017-01-20T17:42:47.789-07:00[America/Denver]

Between 

判断在时间之内,路由配置才生效

spring:
  cloud:
    gateway:
      routes:
      - id: between_route
        uri: https://example.org
        predicates:
        - Between=2017-01-20T17:42:47.789-07:00[America/Denver], 2017-01-21T17:42:47.789-07:00[America/Denver]

Cookie 

Cookie路由断言接受两个参数,Cookie名称和regexp

判断匹配具有给定名称且其值与正则表达式匹配的cookie

spring:
  cloud:
    gateway:
      routes:
      - id: cookie_route
        uri: https://example.org
        predicates:
        - Cookie=chocolate, ch.p

Header 

Header路由断言工厂接受两个参数,Header名称和regexp(一个Java正则表达式)

判断给定名称且其值与正则表达式匹配的header匹配

spring:
  cloud:
    gateway:
      routes:
      - id: header_route
        uri: https://example.org
        predicates:
        - Header=X-Request-Id, \d+

Host 

主机是yumbo.top或者huashengshu.top的子域名,路由配置才生效

spring:
  cloud:
    gateway:
      routes:
      - id: host_route
        uri: https://example.org
        predicates:
        - Host=**.somehost.org,**.anotherhost.org

Method

请求方法要是配置中设置的GET或者POST,路由配置才生效

spring:
  cloud:
    gateway:
      routes:
      - id: method_route
        uri: https://example.org
        predicates:
        - Method=GET,POST

Path

请求路径要符合Path设置,路由配置才生效

spring:
  cloud:
    gateway:
      routes:
      - id: path_route
        uri: https://example.org
        predicates:
        - Path=/red/{segment},/blue/{segment}

Query 

请求参数要包含green参数,路由配置才生效

spring:
  cloud:
    gateway:
      routes:
      - id: query_route
        uri: https://example.org
        predicates:
        - Query=green

RemoteAddr 

如果请求的远程地址是192.168.1.10,路由配置才生效

spring:
  cloud:
    gateway:
      routes:
      - id: remoteaddr_route
        uri: https://example.org
        predicates:
        - RemoteAddr=192.168.1.1/24

Weight 

路由将80%的流量转发到weighthigh.org,并将20%的流量转发到weighlow.org

spring:
  cloud:
    gateway:
      routes:
      - id: weight_high
        uri: https://weighthigh.org
        predicates:
        - Weight=group1, 8
      - id: weight_low
        uri: https://weightlow.org
        predicates:
        - Weight=group1, 2

更多请查看

Spring Cloud Gateway

你可能感兴趣的:(微服务,gateway,java,servlet)