StripPrefix GatewayFilter Factory

StripPrefix GatewayFilter 工厂采用一个参数 partsparts 参数指示在将请求发往下游之前要从路径中移除的部分数。以下清单配置 StripPrefix GatewayFilter

application.yml
spring:
  cloud:
    gateway:
      routes:
      - id: nameRoot
        uri: https://nameservice
        predicates:
        - Path=/name/**
        filters:
        - StripPrefix=2

当通过网关向 /name/blue/red 发出请求时,向 nameService 发出的请求看上去就像 https://nameservice/red