Request and response body conversion
In Chapter 10, Implementing MVC Pattern in a Web Application with Spring, we discussed message conversion for the request body and response body either from Java to JSON, or from JSON to Java object, and many more. Similarly, conversion is also required in the case of a Reactive web application, . The spring core module provides reactive Encoder and Decoder to enable the serialization of a Flux of bytes to and from the typed objects.
Let's see the following example for request body type conversions. Developers do not need to forcefully do type conversion--the Spring Framework automatically converts it for you in both types of approaches: Annotation-based programming, and functional-based programming.
- Account account: This means that the account object is deserialized before the controller is called without blocking.
- Mono<Account> account: This means that
AccountController
can use the Mono to declare logic. The account object is first deserialized,...