Skip to content

Instantly share code, notes, and snippets.

@auryn31
Last active Nov 2, 2019
Embed
What would you like to do?
@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