Small question regarding some return type I have seen for Spring Webflux please.
In many examples, like online tutorials, the rest web controller of a Spring Webflux project will return a Mono of MyPojo Mono<MyPojo> something like
public Mono<MyPojo> monoPojo(String parameter) {
return WebClient.create("http://...").get().retrieve().bodyToMono(MyPojo.class)
.map(oneMyPojo -> unregisterRepository.insert(oneMyPojo))
;
}
But I am also bumping into projects where it returns the response entity, the Mono of response entity of MyPojo Mono<ResponseEntity<MyPojo>>:
public Mono<ResponseEntity<MyPojo>> monoResponseEntityPojo(String parameter) {
return WebClient.create("http://...").get().retrieve().bodyToMono(MyPojo.class)
.map(oneMyPojo -> unregisterRepository.insert(oneMyPojo))
.map(ResponseEntity::ok)
;
}
I am having a hard time understanding the use of Mono<ResponseEntity>. May I ask what kind of benefits this Mono<ResponseEntity> can bring over Mono please?
Thank you