'Benefits of having Mono as parameter?

What are the benefits of having Mono as parameter in HTTP endpoint handler methods?

Let's say I have this code:

public Mono<ResponseDto> handle (@RequestBody Mono<RequestBodyDto> requestBody) {
   return requestBody
        .flatMap(service::doSomething)
        .doOnError(%printError with requestBody%);
}

I want to log the request in an error log, but I do not have access to it in error handling lambda. I can't call requestBody.block().

Why I can't just do this:

public Mono<ResponseDto> handle (@RequestBody RequestBodyDto requestBody) {
   return Mono.just(requestBody)
        .flatMap(service::doSomething)
        .doOnError(%printError with requestBody%);
}

?

In this case I have access to requestBody via the method parameter.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source