Reputation: 1767
I just created a new Ktor project, but following the docs, I am unsure where to import Plugin "install" function.
import io.ktor.server.engine.*
import io.ktor.server.netty.*
import io.netty.handler.codec.DefaultHeaders
fun main() {
embeddedServer(Netty, port = 8080, host = "0.0.0.0") {
install(DefaultHeaders)
install(CallLogging)
install(Koin) {
slf4jLogger()
modules(helloAppModule)
}
configurePlugins()
configureRouting()
}.start(wait = true)
}
My IDE has several suggestions, none of which seem to resolve correctly. I am using Ktor version 2.0.0.
Upvotes: 0
Views: 1053
Reputation: 88327
The problem is that you have incorrect Default headers import.
Make sure you have it as dependency:
implementation("io.ktor:ktor-server-default-headers:$ktor_version")
Replace
import io.netty.handler.codec.DefaultHeaders
with
import io.ktor.server.plugins.defaultheaders.*
IDE should suggest you the following import for install
:
import io.ktor.server.application.*
Upvotes: 2