Created
February 19, 2019 15:55
-
-
Save freeone3000/69611dcb8ca9417382cbb13e788233eb to your computer and use it in GitHub Desktop.
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
private suspend fun ApplicationCall.respondStoryWith(sessionFactory: SessionFactory) { | |
try { | |
findStoryStream(parameters["id"]!!, sessionFactory).use { stream -> | |
respondBytes(io.ktor.http.ContentType.parse("application/x-zmachine"), io.ktor.http.HttpStatusCode.OK) { | |
stream.readAllBytes() //TODO ??? | |
} | |
} | |
} catch(ex: UnsupportedOperationException) { | |
respond(io.ktor.http.HttpStatusCode.NotFound, ex.message ?: "Resource not found") | |
} catch(ex: IllegalArgumentException) { | |
respond(io.ktor.http.HttpStatusCode.BadRequest, ex.message ?: "Invalid target name") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment