October 2018
Intermediate to advanced
590 pages
15h 5m
English
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 ...Read now
Unlock full access