Hi team, I have some troubles getting Ktor server ...
# ktor
t
Hi team, I have some troubles getting Ktor server on a Kotlin Native target the routing up and running for serving static files.
Copy code
routing {
    get("/") {
        call.respondText("Hi") // works

        val bytes = resource("index.html").readBytes() // resources method not found
        call.respondText(contentType = ContentType.Text.Html, text = bytes.decodeToString())
    }

    // staticResources not found
    staticResources("/", "static") {
        default("index.html")
        preCompressed(CompressedFileType.GZIP)
   }
}
Is this a limitation of Kotlin native or did I miss something else?
1
a
Unfortunately, methods for serving static content are available only on the JVM target.
t
Thanks for the clarification @Aleksei Tirman [JB], just for learning purpose, do you know y?
a
Because a JVM specific API is used there which requires an implementation on the *nix targets.
t
thx 🙂