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.