July 2018
Intermediate to advanced
268 pages
7h 36m
English
HandlerFunction accepts a ServerRequest object and returns Mono<ServerResponse>. Both ServerRequest and ServerResponse objects are immutable and fully reactive, built on top of Reactor.
ServerRequest exposes the body as Mono or Flux. Traditionally, BodyExtractor is used to achieve this. However, it also has utility methods which exposes these objects as shown in the following code. ServerRequest also gives access to all HTTP request elements, such as method, URI, and query string parameters:
Mono<String> helloWorld = request.body(BodyExtractors.toMono(String.class);Mono<String> helloWorldUtil = request.bodyToMono(String.class);Flux<Person> movie = request.body(BodyExtractors.toFlux(Movie.class);Flux<Person> movieUtil = request.bodyToFlux(Movie.class); ...
Read now
Unlock full access