Class RegistrationController

java.lang.Object
io.github.navjotsrakhra.eventmanager.controller.RegistrationController

@RestController @RequestMapping("/register") public class RegistrationController extends Object
The RegistrationController class handles HTTP requests related to user registration.
  • Constructor Details

    • RegistrationController

      public RegistrationController(UserRegistrationService userRegistrationService)
      Constructor for the RegistrationController class.
      Parameters:
      userRegistrationService - Service for user registration.
  • Method Details

    • register

      @PostMapping public String register(@RequestBody RegistrationFormDTO registrationFormDTO) throws UserNameTakenException
      Handles POST requests for the "/register" URL to register a new user.
      Parameters:
      registrationFormDTO - The RegistrationFormDTO object containing user registration information. Specifically username and password
      Returns:
      A String representing the registration result.
      Throws:
      UserNameTakenException - if the username is already taken.
    • usernameTakenExceptionHandler

      @ExceptionHandler(UserNameTakenException.class) public org.springframework.http.ResponseEntity<String> usernameTakenExceptionHandler(UserNameTakenException e)
      Handles exceptions related to a username already being taken.
      Parameters:
      e - The UserNameTakenException.
      Returns:
      ResponseEntity with a CONFLICT status and an error message.