public static Mono<ServerWebExchange> rewriteRequestBody(final ServerWebExchange exchange,
                                                             final List<HttpMessageReader<?>> readers,
                                                             final Function<String, Mono<String>> convert) {

        ServerRequest serverRequest = ServerRequest.create(exchange, readers);
        CachedBodyOutputMessage outputMessage = ResponseUtils.newCachedBodyOutputMessage(exchange);

        return serverRequest.bodyToMono(String.class)
                .switchIfEmpty(Mono.defer(() -> Mono.just("")))
                .flatMap(convert)
                .flatMap(body -> {
                    BodyInserter<String, ReactiveHttpOutputMessage> bodyInserter = BodyInserters.fromValue(body);
                    return bodyInserter.insert(outputMessage, new BodyInserterContext());
                }).then(Mono.defer(() -> {
                    ServerHttpRequestDecorator decorator = new RequestDecorator(exchange, outputMessage);
                    return Mono.just(exchange.mutate().request(decorator).build());
                })).onErrorResume(throwable -> ResponseUtils.release(outputMessage, throwable));

    }
Rewrites Request Body.

@param exchange serverWebExchange
@param readers  reader to read request-body
@param convert  convert body to new body
@return Mono.
shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/utils/ServerWebExchangeUtils.java