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.