Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.

Commit

Permalink
Merge pull request #174 from Z-Jais/master
Browse files Browse the repository at this point in the history
Add deleteAnime function to AnimeController
  • Loading branch information
Ziedelth authored Oct 4, 2023
2 parents 3d1c913 + b03a957 commit 20d4baa
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/main/kotlin/fr/ziedelth/controllers/AnimeController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,29 @@ class AnimeController : AttachmentController<Anime>("/animes") {
}
}

@APIRoute
private fun Route.deleteAnime() {
delete("/{uuid}") {
try {
val uuid = UUID.fromString(call.parameters["uuid"]!!)
println("DELETE $prefix/$uuid")
if (isUnauthorized()) return@delete
val savedAnime = animeRepository.find(uuid)

if (savedAnime == null) {
call.respond(HttpStatusCode.NotFound, "Anime not found")
return@delete
}

animeRepository.delete(savedAnime)
animeService.invalidateAll()
call.respond(HttpStatusCode.NoContent)
} catch (e: Exception) {
printError(call, e)
}
}
}

@APIRoute
private fun Route.merge() {
put("/merge") {
Expand Down

0 comments on commit 20d4baa

Please sign in to comment.