package de.springbootbuch.reactive.filmstore;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

/**
 * Part of springbootbuch.de.
 * @author Michael J. Simons
 * @author @rotnroll666
 */
@RestController
public class FilmRestController {
	
	private final FilmRepository filmRepository;

	public FilmRestController(FilmRepository filmRepository) {
		this.filmRepository = filmRepository;
	}
	
	@GetMapping("/api/films")
	public Flux<Film> getAll() {
		return filmRepository.findAll();
	}
}
@@ -99,16 +99,77 @@
 apping;%0A
+import org.springframework.web.bind.annotation.PathVariable;%0A
 import o
@@ -258,16 +258,52 @@
 er.Flux;
+%0Aimport reactor.core.publisher.Mono;
 %0A%0A/**%0A *
@@ -330,16 +330,20 @@
 uch.de.%0A
+ * %0A
  * @auth
@@ -690,9 +690,406 @@
 l();%0A%09%7D%0A
+%09%0A%09@GetMapping(%22/api/films/%7Bid%7D%22)%0A%09public Mono%3CFilm%3E getFilm(@PathVariable final String id) %7B%0A%09%09return Mono.justOrEmpty(id)%0A%09%09%09.flatMap(filmRepository::findById);%0A%09%7D%0A%09%0A%09@GetMapping(%22/api/films/%7Bid%7D/actors%22)%0A%09public Flux%3CActor%3E getActors(@PathVariable final String id) %7B%0A%09%09return Mono.justOrEmpty(id)%0A%09%09%09.flatMap(filmRepository::findById)%0A%09%09%09.flatMapMany(f -%3E Flux.fromIterable(f.getActors()));%0A%09%7D%0A
 %7D

Add more example