From ad1dc247dc8f8b3fd1e8bb29f7256ca601d3cde6 Mon Sep 17 00:00:00 2001 From: young891221 Date: Wed, 16 Jan 2019 16:39:02 +0900 Subject: [PATCH] create HandlerStrategies only one --- .../rewrite/ModifyRequestBodyGatewayFilterFactory.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/factory/rewrite/ModifyRequestBodyGatewayFilterFactory.java b/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/factory/rewrite/ModifyRequestBodyGatewayFilterFactory.java index 402cea0ce..8874109d0 100644 --- a/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/factory/rewrite/ModifyRequestBodyGatewayFilterFactory.java +++ b/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/factory/rewrite/ModifyRequestBodyGatewayFilterFactory.java @@ -17,10 +17,13 @@ package org.springframework.cloud.gateway.filter.factory.rewrite; +import java.util.List; import java.util.Map; import org.springframework.cloud.gateway.support.BodyInserterContext; import org.springframework.cloud.gateway.support.CachedBodyOutputMessage; +import org.springframework.http.codec.HttpMessageReader; +import org.springframework.web.reactive.function.server.HandlerStrategies; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -41,8 +44,11 @@ import org.springframework.web.reactive.function.server.ServerRequest; public class ModifyRequestBodyGatewayFilterFactory extends AbstractGatewayFilterFactory { + private final List> messageReaders; + public ModifyRequestBodyGatewayFilterFactory() { super(Config.class); + this.messageReaders = HandlerStrategies.withDefaults().messageReaders(); } @Deprecated @@ -55,8 +61,7 @@ public class ModifyRequestBodyGatewayFilterFactory public GatewayFilter apply(Config config) { return (exchange, chain) -> { Class inClass = config.getInClass(); - - ServerRequest serverRequest = new DefaultServerRequest(exchange); + ServerRequest serverRequest = new DefaultServerRequest(exchange, this.messageReaders); //TODO: flux or mono Mono modifiedBody = serverRequest.bodyToMono(inClass) // .log("modify_request_mono", Level.INFO)