例如
spring:
cloud:
gateway:
routes:
- id: hystrix_route
uri: https://xxxxxxxxxxxx.a.run.app
predicates:
- Path=/model/**
filters:
- name: Hystrix
args:
name: fallbackcmd
fallbackUri: forward:/incaseoffailureusethis
- RewritePath=/model(?<segment>/?.*), $\{segment}
我希望能够向符合该谓词/ model / **的所有请求添加标头
以下是执行请求以获取标头值的代码的示例(顺便说一句,receiveingURL是目标uri:https://xxxxxxxxxxxx.a.run.app
var url = "http://metadata/computeMetadata/v1/instance/service-accounts/default/identity?audience=";
var token = webClient
.get()
.uri(url + receivingURL)
.header("Metadata-Flavor", "Google")
.retrieve()
.bodyToMono(String.class);
仅供参考:用例是网关在GKE中运行,并且某些端点已部署到Cloud Run。