Creating Mono<T> and Flux<T> HTTP response
The Spring WebFlux paradigm will not be complete without the @Controller returning Mono<T> and Flux<T> stream data.
Getting started
Add in project ch08 a set of request handlers that returns on the client Mono<T> and Flux<T> through @ResponseBody annotation.
How to do it...
After using Reactor Core specification to build the service layer, let us apply Mono<T> and Flux<T> streams to @Controllers by doing these steps:
- Open the
ServiceControllerof the previous recipe again and add the following request handler showcasing the use of Reactor Stream operations:
@RequestMapping(value="/web/employeeNames.json",
produces ="application/json",
method = RequestMethod.GET,
headers = {"Accept=text/xml, application/json"})
@ResponseBody
public Callable<List<String>> jsonEmpNames(){
Callable<List<String>> task =
new Callable<List<String>>() {
@Override
...