RemoveRequestHeader GatewayFilter Factory

RemoveRequestHeader 过滤器采用一个 name 参数。它是被删除的头的名称。以下列表配置一个 RemoveRequestHeader 过滤器:

application.yml
spring:
  cloud:
    gateway:
      mvc:
        routes:
        - id: removerequestheader_route
          uri: https://example.org
          filters:
          - RemoveRequestHeader=X-Request-Foo
GatewaySampleApplication.java
import static org.springframework.cloud.gateway.server.mvc.filter.BeforeFilterFunctions.removeRequestHeader;
import static org.springframework.cloud.gateway.server.mvc.handler.GatewayRouterFunctions.route;
import static org.springframework.cloud.gateway.server.mvc.handler.HandlerFunctions.http;

@Configuration
class RouteConfiguration {

    @Bean
    public RouterFunction<ServerResponse> gatewayRouterFunctionsremoveRequestHeader() {
		return route("removerequestheader_route")
				.GET("/**", http("https://example.org"))
					.before(removeRequestHeader("X-Request-Foo"))
					.build();
    }
}

这在将 X-Request-Foo 头向下发送之前将其移除。