RemoveRequestParameter Filter

RemoveRequestParameter 过滤器采用一个 name 参数。它是被删除的查询参数的名称。以下示例配置一个 RemoveRequestParameter 过滤器:

application.yml
spring:
  cloud:
    gateway:
      mvc:
        routes:
        - id: removerequestparameter_route
          uri: https://example.org
          filters:
          - RemoveRequestParameter=red
GatewaySampleApplication.java
import static org.springframework.cloud.gateway.server.mvc.filter.BeforeFilterFunctions.addRequestParameter;
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> gatewayRouterFunctionsAddReqHeader() {
		return route("removerequestparameter_route")
				.GET("/**", http("https://example.org"))
					.before(removeRequestParameter("red"))
					.build();
    }
}

这将在将 red 参数下行发送之前将其移除。