Skip to content

Instantly share code, notes, and snippets.

@kzdelarec
Created June 29, 2020 13:09
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save kzdelarec/c4b112e6a861361b188b31ad004cc925 to your computer and use it in GitHub Desktop.
@RestController
@RequestMapping("/api/article")
class ArticleController(private val repository: ArticleRepository) {
@GetMapping("/")
fun findAll() = repository.findAllByOrderByAddedAtDesc()
@GetMapping("/{id}")
fun findOne(@PathVariable id: UUID) =
repository.findBySlug(slug) ?: ResponseStatusException(HttpStatus.NOT_FOUND, "This article does not exist")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment