Spring Cloud RewriteResponseHeader GatewayFilter工廠

2024-01-05 17:36 更新

RewriteResponseHeader GatewayFilter工廠采用name,regexpreplacement參數(shù)。它使用Java正則表達(dá)式以靈活的方式重寫響應(yīng)標(biāo)頭值。

application.yml。 

spring:
  cloud:
    gateway:
      routes:
      - id: rewriteresponseheader_route
        uri: https://example.org
        filters:
        - RewriteResponseHeader=X-Response-Foo, , password=[^&]+, password=***

對于標(biāo)頭值為/42?user=ford&password=omg!what&flag=true,在發(fā)出下游請求后它將被設(shè)置為/42?user=ford&password=***&flag=true。由于YAML規(guī)范,請使用$\來表示$。

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

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號