I have next endpoint in my application:
@GetMapping(value = "/users")
public Mono<ServerResponse> users() {
Flux<User> flux = Flux.just(new User("id"));
return ServerResponse.ok()
.contentType(APPLICATION_JSON)
.body(flux, User.class)
.onErrorResume(CustomException.class, e -> ServerResponse.notFound().build());
}
Currently I can see text "data:"
as a body and Content-Type →text/event-stream
in Postman. As I understand Mono<ServerResponse>
always return data with SSE(Server Sent Event)
.
Is it possible to somehow view response in Postman client?
It seems you're mixing the annotation model and the functional model in WebFlux. The
ServerResponse
class is part of the functional model.Here's how to write an annotated endpoint in WebFlux:
Here's the functional way now: