diff --git a/samples/html5Canvas/src/httpServerMain/kotlin/HttpServer.kt b/samples/html5Canvas/src/httpServerMain/kotlin/HttpServer.kt index 5653e3f61db..a9e76dc20ba 100644 --- a/samples/html5Canvas/src/httpServerMain/kotlin/HttpServer.kt +++ b/samples/html5Canvas/src/httpServerMain/kotlin/HttpServer.kt @@ -7,9 +7,14 @@ package sample.html5canvas.httpserver +import io.ktor.application.call +import io.ktor.http.ContentType +import io.ktor.http.content.LocalFileContent import io.ktor.http.content.default import io.ktor.http.content.files import io.ktor.http.content.static +import io.ktor.response.respond +import io.ktor.routing.get import io.ktor.routing.routing import io.ktor.server.engine.embeddedServer import io.ktor.server.netty.Netty @@ -34,6 +39,16 @@ fun main(args: Array) { val server = embeddedServer(Netty, 8080) { routing { + val wasm = "build/bin/html5Canvas/releaseExecutable/html5Canvas.wasm" + get(wasm) { + // TODO: ktor as of now doesn't know about 'application/wasm'. + // The newer browsers (firefox and chrome at least) don't allow + // 'application/octet-stream' for wasm anymore. + // We provide the proper content type here and, + // at the same time, put it into the ktor database. + // Remove this whole get() clause when ktor fix is available. + call.respond(LocalFileContent(File(wasm), ContentType("application", "wasm"))) + } static("/") { files(contentRoot) default("index.html")