SetPath GatewayFilter 工厂
SetPath GatewayFilter Factory
SetPath GatewayFilter 工厂接收一个路径 template 参数。它提供了一种简单的方式来操作请求路径,允许使用路径的模板化片段。这使用了 Spring Framework 中的 URI 模板。允许多个匹配的片段。以下示例配置了一个 SetPath GatewayFilter:
spring:
cloud:
gateway:
routes:
- id: setpath_route
uri: https://example.org
predicates:
- Path=/red/{segment}
filters:
- SetPath=/{segment}
对于请求路径 /red/blue,这会在发起下游请求之前将路径设置为 /blue。