Created
June 29, 2020 13:09
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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