Search code examples
kotlinktorkotlin-native

Ktor's function `staticResources` is not available on Kotlin native targets


I'm running a simple Ktor server on a Kotlin Native target.

The server should only serve a static html page. I checked the Ktor sample on delivering static content but neither staticResources nor static or staticFiles is available to be imported.

...
routing {
    staticResources("/static", "assets", index = "my_index.html") 
    // staticResources not found as function
}
...

What builds is e.g.:

embeddedServer(CIO, port = 8080) {
    routing {
        get("/") {
            call.respondText("Hi") // works
        }
    }
}.start()

I cannot read or see any limitation of Ktor or the CIO engine that relates to this error.


Solution

  • Answer

    Please see comments under the original post. staticResource, etc. are only supported on a JVM target.