In this section, we will go into a bit more detail on Spring WebFlux. There are two (programming model) ways by which Spring WebFlux can be used. They are as follows:
- Using annotations: By using annotations such as @Controller similar to how it is been done in Spring MVC
- Using functional style: By using routing and handling with Java Lambdas
The following code shows the annotation-based style of using Spring WebFlux. We will be going through the entire code sample in subsequent sections in this chapter. This section, however, is aimed at giving an introduction before we delve deeper:
@RestController
@RequestMapping(value=”/api/movie”)
public class MovieAPI {
@GetMapping(“/”)
public Flux(Movie) getMovies() {
//Logic of getting all movies
}
@GetMapping(“/{id}”)
public Mono<Movie> getMovie(@PathVariable...