Find the code snippet for the getAllUserByID() operation:
// Getting one User by ID
@GetMapping(path = ["/user/{id}"])
fun getAllUserByID(@PathVariable("id") id: Int): ResponseEntity<UserModel> {
return ResponseEntity(userService.getUserByID(id),
HttpStatus.OK)
}
The @GetMapping(path = ["/user/{id}"]) annotation is the URL path of "/user/{id}", and it is a GET request with a specific ID. Here, we will get the specific user details from the database.