MapRequestHeader GatewayFilter Factory

MapRequestHeader GatewayFilter 工厂采用 fromHeadertoHeader 参数。它创建了一个新命名的标头(toHeader),并且该值是从传入 http 请求中的现有命名标头(fromHeader)中提取出来的。如果输入标头不存在,则过滤器没有影响。如果新命名的标头已存在,则其值会用新值扩充。以下示例配置了 MapRequestHeader

The MapRequestHeader GatewayFilter factory takes fromHeader and toHeader parameters. It creates a new named header (toHeader), and the value is extracted out of an existing named header (fromHeader) from the incoming http request. If the input header does not exist, the filter has no impact. If the new named header already exists, its values are augmented with the new values. The following example configures a MapRequestHeader:

application.yml
spring:
  cloud:
    gateway:
      routes:
      - id: map_request_header_route
        uri: https://example.org
        filters:
        - MapRequestHeader=Blue, X-Request-Red

这会向附带来自传入 HTTP 请求的 “Blue” 标头已更新值的向下请求添加 “X-Request-Red:<values>` 标头。

This adds the X-Request-Red:<values> header to the downstream request with updated values from the incoming HTTP request’s Blue header.