StripPrefix GatewayFilter 工厂

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 发送的请求看起来像 nameservice/red

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