W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗(yàn)值獎勵
Host
Route Predicate Factory采用一個參數(shù):主機(jī)名patterns
的列表。模式是Ant樣式的模式,以.
作為分隔符。該謂詞與匹配模式的Host
頭匹配。
application.yml。
spring: cloud: gateway: routes: - id: host_route uri: https://example.org predicates: - Host=**.somehost.org,**.anotherhost.org
還支持URI模板變量,例如{sub}.myhost.org
。
如果請求的Host
標(biāo)頭的值為www.somehost.org
或beta.somehost.org
或www.anotherhost.org
,則此路由將匹配。
該謂詞提取URI模板變量(如上例中定義的sub
)作為名稱和值的映射,并使用在ServerWebExchangeUtils.URI_TEMPLATE_VARIABLES_ATTRIBUTE
中定義的鍵將其放置在ServerWebExchange.getAttributes()
中。這些值可供GatewayFilter工廠使用。
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: