Modify Request Body for a GET request
#1147 opened on Jul 3, 2019
Description
We currently have custom code for modifying request body which works but I want to move to the standard ModifyRequestBodyGatewayFilterFactory.
We have a scenario where Spring Cloud Gateway received a GET request and we need call an internal GraphQL api with a POST and a request body.
ModifyRequestBodyGatewayFilterFactory works great if there is a body present in the original request but doesn't apply the rewriteFunction when there is no body on GET requests.
I am using v2.1.2.RELEASE and I have hacked together a change to ModifyRequestBodyGatewayFilterFactory which works for me:
Mono<?> modifiedBody = serverRequest.bodyToMono(inClass)
.defaultIfEmpty("") //added this line
.flatMap(o -> config.rewriteFunction.apply(exchange, o));
I appreciate that the ModifyRequestBodyGatewayFilterFactory is beta, but would it be possible to support adding a body for GET requests in the future?