moremind commented on issue #4477:
URL: https://github.com/apache/shenyu/issues/4477#issuecomment-1473000505

   reactor of spring-webflux is asynchronous,but you can get request body as 
follows:
   
   
   ```java
   ServerRequest serverRequest = ServerRequest.create(exchange, 
MESSAGE_READERS);
               Mono<String> mono = serverRequest.bodyToMono(String.class)
                       .switchIfEmpty(Mono.defer(() -> Mono.just("")))
                       .flatMap(originalBody -> signBody(originalBody, 
exchange));
   
               BodyInserter<Mono<String>, ReactiveHttpOutputMessage> 
bodyInserter = BodyInserters.fromPublisher(mono, String.class);
               CachedBodyOutputMessage outputMessage = 
ResponseUtils.newCachedBodyOutputMessage(exchange);
               return bodyInserter.insert(outputMessage, new 
BodyInserterContext())
                       .then(Mono.defer(() -> {
                           ServerHttpRequestDecorator decorator = new 
SignRequestDecorator(exchange, outputMessage);
                           return 
chain.execute(exchange.mutate().request(decorator).build());
                       })).onErrorResume((Function<Throwable, Mono<Void>>) 
throwable -> ResponseUtils.release(outputMessage, throwable));
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to