Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@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