content: package com.example.identityservice.auth;
  
  import lombok.RequiredArgsConstructor;
  import org.springframework.http.HttpStatus;
  import org.springframework.http.ResponseEntity;
  import org.springframework.web.bind.annotation.PostMapping;
  import org.springframework.web.bind.annotation.RequestBody;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RestController;
  
  @RestController
  @RequestMapping("/api/auth")
  @RequiredArgsConstructor
  public class AuthenticationController {
  
      private final AuthenticationService service;
  
      @PostMapping("/register")
      public ResponseEntity<Object> register(@RequestBody RegisterRequest request) {
          try {
              return ResponseEntity.ok(service.register(request));
          } catch (IllegalArgumentException e) {
              return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(e.getMessage());
          }
      }
  
      @PostMapping("/authenticate")
      public ResponseEntity<AuthenticationResponse> register(@RequestBody AuthenticationRequest request) {
          return ResponseEntity.ok(service.authenticate(request));
      }
  }
  