SetPath GatewayFilter 工厂

SetPath GatewayFilter 工厂接受一个路径 template 参数。它通过允许路径的模板化段提供一种简单的方式来操作请求路径。这使用了 Spring 框架的 URI 模板。允许匹配多个段。以下示例配置了一个 SetPath GatewayFilter

application.yml
spring:
  cloud:
    gateway:
      routes:
      - id: setpath_route
        uri: https://example.org
        predicates:
        - Path=/red/{segment}
        filters:
        - SetPath=/{segment}

对于请求路径 /red/blue,这会在发起下游请求之前将路径设置为 /blue

© . This site is unofficial and not affiliated with VMware.