Browse Source

Marks reading/modifying request/response body as BETA.

pull/365/head^2
Spencer Gibb 7 years ago
parent
commit
a6ff180919
No known key found for this signature in database
GPG Key ID: 7788A47380690861
  1. 4
      spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/factory/AbstractGatewayFilterFactory.java
  2. 1
      spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/factory/rewrite/HttpMessageWriterResponse.java
  3. 3
      spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/factory/rewrite/ModifyRequestBodyGatewayFilterFactory.java
  4. 3
      spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/factory/rewrite/ModifyResponseBodyGatewayFilterFactory.java
  5. 5
      spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/factory/rewrite/RewriteFunction.java
  6. 3
      spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/factory/rewrite/RewriteUtils.java
  7. 3
      spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/handler/predicate/ReadBodyPredicateFactory.java
  8. 18
      spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/route/builder/GatewayFilterSpec.java
  9. 1
      spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/route/builder/PredicateSpec.java

4
spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/factory/AbstractGatewayFilterFactory.java

@ -19,6 +19,10 @@ package org.springframework.cloud.gateway.filter.factory; @@ -19,6 +19,10 @@ package org.springframework.cloud.gateway.filter.factory;
import org.springframework.cloud.gateway.support.AbstractConfigurable;
/**
* This class is BETA and may be subject to change in a future release.
* @param <C>
*/
public abstract class AbstractGatewayFilterFactory<C>
extends AbstractConfigurable<C> implements GatewayFilterFactory<C> {

1
spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/factory/rewrite/HttpMessageWriterResponse.java

@ -31,6 +31,7 @@ import reactor.core.publisher.Mono; @@ -31,6 +31,7 @@ import reactor.core.publisher.Mono;
import java.util.function.Supplier;
/**
* This class is BETA and may be subject to change in a future release.
* Response who's job it is to gather the Publisher&lt;DataBuffer&gt; from the writeWith message
* during a call to HttpMessageWriter.write. Also gathers any headers set there.
*/

3
spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/factory/rewrite/ModifyRequestBodyGatewayFilterFactory.java

@ -37,6 +37,9 @@ import org.springframework.http.server.reactive.ServerHttpRequestDecorator; @@ -37,6 +37,9 @@ import org.springframework.http.server.reactive.ServerHttpRequestDecorator;
import static org.springframework.cloud.gateway.filter.factory.rewrite.RewriteUtils.process;
/**
* This filter is BETA and may be subject to change in a future release.
*/
public class ModifyRequestBodyGatewayFilterFactory
extends AbstractGatewayFilterFactory<ModifyRequestBodyGatewayFilterFactory.Config> {

3
spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/factory/rewrite/ModifyResponseBodyGatewayFilterFactory.java

@ -43,6 +43,9 @@ import org.springframework.web.server.ServerWebExchange; @@ -43,6 +43,9 @@ import org.springframework.web.server.ServerWebExchange;
import static org.springframework.cloud.gateway.filter.factory.rewrite.RewriteUtils.getHttpMessageReader;
import static org.springframework.cloud.gateway.filter.factory.rewrite.RewriteUtils.getHttpMessageWriter;
/**
* This filter is BETA and may be subject to change in a future release.
*/
public class ModifyResponseBodyGatewayFilterFactory
extends AbstractGatewayFilterFactory<ModifyResponseBodyGatewayFilterFactory.Config> {

5
spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/factory/rewrite/RewriteFunction.java

@ -21,5 +21,10 @@ import org.springframework.web.server.ServerWebExchange; @@ -21,5 +21,10 @@ import org.springframework.web.server.ServerWebExchange;
import java.util.function.BiFunction;
/**
* This interface is BETA and may be subject to change in a future release.
* @param <T>
* @param <R>
*/
public interface RewriteFunction<T, R> extends BiFunction<ServerWebExchange, T, R> {
}

3
spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/factory/rewrite/RewriteUtils.java

@ -30,6 +30,9 @@ import org.springframework.http.codec.CodecConfigurer; @@ -30,6 +30,9 @@ import org.springframework.http.codec.CodecConfigurer;
import org.springframework.http.codec.HttpMessageReader;
import org.springframework.http.codec.HttpMessageWriter;
/**
* This class is BETA and may be subject to change in a future release.
*/
public abstract class RewriteUtils {
public static <T, R> R process(Mono<T> mono, Function<T, R> consumer) {

3
spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/handler/predicate/ReadBodyPredicateFactory.java

@ -37,6 +37,9 @@ import static org.springframework.cloud.gateway.filter.factory.rewrite.RewriteUt @@ -37,6 +37,9 @@ import static org.springframework.cloud.gateway.filter.factory.rewrite.RewriteUt
import static org.springframework.cloud.gateway.filter.factory.rewrite.RewriteUtils.getHttpMessageWriter;
import static org.springframework.cloud.gateway.filter.factory.rewrite.RewriteUtils.process;
/**
* This predicate is BETA and may be subject to change in a future release.
*/
public class ReadBodyPredicateFactory extends AbstractRoutePredicateFactory<ReadBodyPredicateFactory.Config> {
private final ServerCodecConfigurer codecConfigurer;

18
spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/route/builder/GatewayFilterSpec.java

@ -127,11 +127,29 @@ public class GatewayFilterSpec extends UriSpec { @@ -127,11 +127,29 @@ public class GatewayFilterSpec extends UriSpec {
return filter(factory.apply(this.routeBuilder.getId(), configConsumer));
}
/**
* This filter is BETA and may be subject to change in a future release.
* @param inClass
* @param outClass
* @param rewriteFunction
* @param <T>
* @param <R>
* @return
*/
public <T, R> GatewayFilterSpec modifyRequestBody(Class<T> inClass, Class<R> outClass, RewriteFunction<T, R> rewriteFunction) {
return filter(getBean(ModifyRequestBodyGatewayFilterFactory.class)
.apply(c -> c.setRewriteFunction(inClass, outClass, rewriteFunction)));
}
/**
* This filter is BETA and may be subject to change in a future release.
* @param inClass
* @param outClass
* @param rewriteFunction
* @param <T>
* @param <R>
* @return
*/
public <T, R> GatewayFilterSpec modifyResponseBody(Class<T> inClass, Class<R> outClass, RewriteFunction<T, R> rewriteFunction) {
return filter(getBean(ModifyResponseBodyGatewayFilterFactory.class)
.apply(c -> c.setRewriteFunction(inClass, outClass, rewriteFunction)));

1
spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/route/builder/PredicateSpec.java

@ -170,6 +170,7 @@ public class PredicateSpec extends UriSpec { @@ -170,6 +170,7 @@ public class PredicateSpec extends UriSpec {
}
/**
* This predicate is BETA and may be subject to change in a future release.
* A predicate that checks the contents of the request body
* @param inClass the class to parse the body to
* @param predicate a predicate to check the contents of the body

Loading…
Cancel
Save