Using Spring WebFlux for a controller
Controllers are the integration point between Model and Resources in an AI. They act like the glue that binds together everything while taking care of business logic execution and response. The following Maven starter dependency
needs to be added to enable Spring WebFlux:
<dependencies> ... <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-webflux</artifactId> </dependency> </dependencies>
The preceding dependency will import Reactive Stream, Spring, and Netty dependencies to enable successful writing of Reactive-based web applications using Spring.
Implementation of controllers
The following code is the TaxiController
, which caters to the registering, searching, status updating, and so on, of Taxis; it is available in spring-boot-2-taxi-service
:
@RequestMapping("/taxis") @RestController public class TaxiController { private final TaxiService taxiService...