Implement RegistrationApiController and its dependencies

Now, let's move on to implement RegistrationApiControler and its dependencies. The full name of the controller is com.taskagile.web.apis.RegistrationApiController, and it looks like the following:

...@Controllerpublic class RegistrationApiController {  private UserService service;  public RegistrationApiController(UserService service) {    this.service = service;  }  @PostMapping("/api/registrations")  public ResponseEntity<ApiResult> register(      @Valid @RequestBody RegistrationPayload payload) {    try {      service.register(payload.toCommand());      return Result.created();    } catch (RegistrationException e) {    String errorMessage = "Registration failed";      if (e instanceof UsernameExistsException) { errorMessage ...

Get Building Applications with Spring 5 and Vue.js 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.