@RestController: Spring’s annotation to signal that this class doesn’t process templates but instead that all outputs are directly serialized to the HTML response
EmployeeRepository: We are injecting the repository we defined earlier in this section through constructor injection
@GetMapping: Maps HTTP GET /api/employees calls to this method
Flux
repository.findAll(): By using the prebuilt findAll method from Spring Data Commons’ ReactiveCrudRepository interface, we already have a method that will fetch all the data
xxxxxxxxxx
@RestController
public class ApiController {
private final EmployeeRepository repository;
public ApiController(EmployeeRepository repository) {
this.repository = repository;
}
}
@GetMapping("/api/employees")
Flux<Employee> employees() {
return repository.findAll();
}