Spring Cloud SetPath GatewayFilter工廠

2024-01-05 17:36 更新

SetPath GatewayFilter工廠采用路徑template參數(shù)。通過允許路徑的模板段,它提供了一種操作請求路徑的簡單方法。這將使用Spring Framework中的uri模板。允許多個匹配段。

application.yml。 

spring:
  cloud:
    gateway:
      routes:
      - id: setpath_route
        uri: https://example.org
        predicates:
        - Path=/foo/{segment}
        filters:
        - SetPath=/{segment}

對于/foo/bar的請求路徑,這將在發(fā)出下游請求之前將路徑設(shè)置為/bar。

以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號