春クラウドゲートウェイ - ルーティングルール

1、ルート述語ファクトリー後

入力パラメータ:時間、マッチング要求その時間後に、構成例:

spring:
  cloud:
    gateway:
      routes:
      - id: after_route
        uri: https://anoyi.com
        predicates:
        - After=2019-11-11T11:11:11.111+08:00[Asia/Shanghai]

ルート述語工場の前に2、

入力パラメータ:時間、対戦要求前の時間、設定例:

spring:
  cloud:
    gateway:
      routes:
      - id: before_route
        uri: https://anoyi.com
        predicates:
        - Before=2019-11-11T11:11:11.111+08:00[Asia/Shanghai]

3、ルート述語工場間

入力二つのパラメータ:時刻1、時刻2、期間マッチング要求、構成例:

spring:
  cloud:
    gateway:
      routes:
      - id: between_route
        uri: https://anoyi.com
        predicates:
        - Between=2019-11-10T11:11:11.111+08:00[Asia/Shanghai], 2019-11-12T11:11:11.111+08:00[Asia/Shanghai]

4、クッキールート述語工場

二つの入力パラメータ:クッキー名、名前の存在および正規表現マッチング、構成例の値で正規表現マッチングクッキー:

spring:
  cloud:
    gateway:
      routes:
      - id: cookie_route
        uri: https://anoyi.com
        predicates:
        - Cookie=name, ano.i

5、ヘッダールート述語工場

二つの入力パラメータ:ヘッダ名、名前の存在および正規表現マッチング、構成例の値で正規表現マッチングヘッダ:

spring:
  cloud:
    gateway:
      routes:
      - id: header_route
        uri: https://anoyi.com
        predicates:
        - Header=name, ano.i

6、ホストルート述語工場

入力パラメータ:ホスト名式リストは、ヘッダーの値は、Hostフィールド、設定例と一致します。

spring:
  cloud:
    gateway:
      routes:
      - id: host_route
        uri: https://anoyi.com
        predicates:
        - Host=**.anoyi.cn,**.anoyi.io

7、メソッドルート述語工場

入力パラメータ:HTTPメソッド、要求メソッドと一致する、構成例:

spring:
  cloud:
    gateway:
      routes:
      - id: method_route
        uri: https://anoyi.com
        predicates:
        - Method=GET

8、パスルート述語工場

二つの入力パラメータ:スプリングPathMatcher式リスト(オプション)matchOptionalTrailingSeparator識別、構成例:

spring:
  cloud:
    gateway:
      routes:
      - id: host_route
        uri: https://anoyi.com
        predicates:
        - Path=/foo/{segment},/bar/{segment}

9、クエリルート述語工場

二つの入力パラメータ:(オプション)正規表現マッチング同様の要求アドレス要求パラメータhttps://anoyi.com/test?hello=world&name=anoyiリクエストパラメータが含まれ、構成例:

# 仅匹配是否包含参数 hello
spring:
  cloud:
    gateway:
      routes:
      - id: query_route
        uri: https://anoyi.com
        predicates:
        - Query=hello
# 匹配参数 name 是否以 ano 开头
spring:
  cloud:
    gateway:
      routes:
      - id: query_route
        uri: https://anoyi.com
        predicates:
        - Query=name, ano.*

10、RemoteAddrはルート述語工場

入力パラメータ:IPv4またはIPv6アドレスリスト、マッチング要求元IPアドレスは、リスト内の典型的な構成です。

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

ブログ記事複数のプラットフォームからこの記事OpenWriteリリース!

おすすめ

転載: www.cnblogs.com/anoyi/p/12001265.html