zoukankan      html  css  js  c++  java
  • SpringCloudGateway内置GatewayFilter工厂类之Path类过滤器 (三)

    1:PrefixPath

      将所有请求路径前加上路径;value

    - PrefixPath=value
    spring:
      cloud:
        gateway:
          routes:
          - id: prefixpath_route
            uri: http://example.org
            filters:
            - PrefixPath=value

    2:RewritePath

      利用路径正则表达式灵活替换请求路径

      eg:

    spring:
        cloud:
            gateway:
                routes:
                #插件请求转发 
                #(?<segment>/?.*):匹配 /任意字符,此处/出现0次或1次。将匹配到的结果捕获到名称为segment的组中
                #$\{segment}:将 segment所捕获到的文本置换到此处,注意,\的出现是由于避免yaml认为这是一个变量,在gateway进行解析时,会被替换为${segment}
                - id: "ms-api-gateway"
                  uri: "lb://ms-api-gateway"
                  predicates:
                  - Path=/isv/mini/common/**
                  filters:
                  - RewritePath=/isv(?<segment>/?.*), /isv/ms/app$\{segment}

    3:SetPath

      SetPath GatewayFilter Factory采用路径模板参数。 它提供了一种通过允许模板化路径段来操作请求路径的简单方法。 这使用了Spring Framework中的uri模板。 允许多个匹配的段。

    - SetPath=/{segment}

      eg:

    spring:
      cloud:
        gateway:
          routes:
          - id: setpath_route
            uri: http://example.org
            predicates:
            - Path=/foo/{segment}
            filters:
            - SetPath=/{segment}

    4:StripPrefix

       StripPrefix网关过滤器工厂采用一个参数StripPrefix。 StripPrefix参数表示在将请求发送到下游之前从请求中剥离的路径个数。

    - StripPrefix

      eg:

    spring:
      cloud:
        gateway:
          routes:
          - id: nameRoot
            uri: http://nameservice
            predicates:
            - Path=/name/**
            filters:
            - StripPrefix=1
  • 相关阅读:
    php smarty使用..
    深圳面试!
    jQuery 源码分析..
    jQuery 使用技巧!!!
    TOMCAT 访问过程...
    准备使用Delphi调用WCF
    Delphi 中Format的字符串格式化使用说明(转载http://hi.baidu.com/test__123/blog/item/e3bba1599d717a2d2834f092.html)
    电脑启动程序自动启动
    判断输入字符串是否等效Int32位数字的两种方法
    vs2005 快捷键
  • 原文地址:https://www.cnblogs.com/jwdd/p/15603912.html
Copyright © 2011-2022 走看看