Add some resources

This commit is contained in:
2025-01-11 18:31:50 +01:00
parent 06803b48a1
commit eaeae11e97
10 changed files with 132 additions and 4 deletions

View File

@@ -0,0 +1,29 @@
package web
import io.ktor.http.*
import io.ktor.server.request.*
import io.ktor.server.response.*
import io.ktor.server.routing.*
import io.ktor.server.websocket.*
import io.ktor.websocket.*
import service.TranslationServiceImpl
import service.TranslationService
fun Route.translation(TranslationService: TranslationServiceImpl) {
route("/translation") {
get {
call.respond(TranslationService.getAllTranslations())
}
get("/{id}") {
val id = call.parameters["id"]?.toInt() ?: throw IllegalStateException("Must provide id")
val Translation = TranslationService.getTranslation(id)
if (Translation == null) call.respond(HttpStatusCode.NotFound)
else call.respond(Translation)
}
}
}