In the code below, when the endpoint getPerson
gets hit, the response will be a JSON of type Person.
How does Spring convert CompletableFuture<Person>
to Person
?
@RestController
public class PersonController {
@Autowired
private PersonService personService;
@GetMapping("/persons/{personId}" )
public CompletableFuture<Person> getPerson(@PathVariable("personId") Integer personId) {
return CompletableFuture.supplyAsync(() -> personService.getPerson(personId));
}
}