UserController

@RestController
@RequestMapping(value = ["/api/v1/user"])
class UserController(service: UserService)

Controller with endpoints to work with user model

Constructors

Link copied to clipboard
constructor(service: UserService)

Functions

Link copied to clipboard
@PostMapping(value = ["/signup"])
@ResponseStatus(value = HttpStatus.OK)
fun createNewUser(@RequestBody newUserDTO: NewUserDto): TokenDto

POST endpoint for creating new user account

Link copied to clipboard
@GetMapping
fun getUserSettings(@RequestHeader(value = "user-token") token: String): UserDto

GET endpoint for listing user settings

Link copied to clipboard
@ExceptionHandler(value = [IllegalArgumentException::class])
fun handleBadRequest(e: IllegalArgumentException): ResponseEntity<String>

Exception bad request handler

Link copied to clipboard
@ExceptionHandler(value = [NoSuchElementException::class])
fun handleNotFound(e: NoSuchElementException): ResponseEntity<String>

Exception not found handler

Link copied to clipboard
@PatchMapping
@ResponseStatus(value = HttpStatus.OK)
fun updateUserSettings(@RequestHeader(value = "user-token") token: String, @RequestBody settings: UpdateUserDto): UserDto

PATCH endpoint for updating user settings