Skip to content

Instantly share code, notes, and snippets.

@auryn31
Last active November 2, 2019 21:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save auryn31/2cef4ea2d5b5cb74f7583127ee3d74d3 to your computer and use it in GitHub Desktop.
Save auryn31/2cef4ea2d5b5cb74f7583127ee3d74d3 to your computer and use it in GitHub Desktop.
@GetMapping("/users/{id}")
fun specificUser(@PathVariable id: Int): ResponseEntity<EntityModel<User>> {
if(dataBean.users.filter { it.id == id }.isEmpty()){
return ResponseEntity(HttpStatus.NOT_FOUND)
}
return ResponseEntity(EntityModel(dataBean.users.filter { it.id == id }.first(),
linkTo(methodOn(UserController::class.java).specificUser(id)).withSelfRel(),
linkTo(methodOn(UserController::class.java).allUsers()).withRel("users")), HttpStatus.OK)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment