diff --git a/src/main/kotlin/moe/kageru/kodeshare/Routes.kt b/src/main/kotlin/moe/kageru/kodeshare/Routes.kt index af4399a..072366f 100644 --- a/src/main/kotlin/moe/kageru/kodeshare/Routes.kt +++ b/src/main/kotlin/moe/kageru/kodeshare/Routes.kt @@ -11,11 +11,13 @@ import io.ktor.http.content.streamProvider import io.ktor.locations.KtorExperimentalLocationsAPI import io.ktor.locations.Location import io.ktor.locations.get +import io.ktor.locations.head import io.ktor.request.receiveMultipart import io.ktor.response.respond import io.ktor.response.respondText import io.ktor.routing.Routing import io.ktor.routing.get +import io.ktor.routing.head import io.ktor.routing.post import moe.kageru.kodeshare.config.ServerSpec import moe.kageru.kodeshare.config.config @@ -54,6 +56,26 @@ object Routes { get { req -> call.handleGet(req) } + head("/") { + call.respond(HttpStatusCode.OK) + } + head { req -> + call.handleHead(req) + } + head { req -> + call.handleHead(req) + } + head { req -> + call.handleHead(req) + } + } + + private suspend fun ApplicationCall.handleHead(paste: AbstractPasteRequest) { + if (PasteDao.selectByUri(paste.uri) != null) { + respond(HttpStatusCode.OK) + } else { + respond(HttpStatusCode.NotFound) + } } @ExperimentalStdlibApi