https://kotlinlang.org logo
#ktor
Title
# ktor
b

Bridgette Powell

03/09/2022, 11:18 PM
Hey there, this is probably a newbie question, but since it’s related to ktor: To get this code below working…why do I have to import both
io.ktor.server.application.call
and
io.ktor.server.response.respondText
? What is it about the
call
property that requires both imports? I would have thought just importing
io.ktor.server.application.call
is enough. Then calling
call.respondText()
is ok, but I get an Unresolved Reference error if I dont include the other import.
Copy code
package com.mobilecoin.plugins

import io.ktor.server.application.Application
import io.ktor.server.application.call
import io.ktor.server.response.respondText
import io.ktor.server.routing.get
import io.ktor.server.routing.routing

fun Application.configureRouting() {

    // Starting point for a Ktor app:
    routing {
        get("/") {
            call.respondText("Hello World!")
        }
    }
    routing {
    }
}
Thanks!
b

Big Chungus

03/09/2022, 11:59 PM
Both are extension functions rather than member
🙏 1
a

Aleksei Tirman [JB]

03/10/2022, 8:18 AM
Here is the information about scope of extension functions.
🙏 1
b

Bridgette Powell

03/10/2022, 9:01 PM
i will read up on this! thanks so much for the info!
7 Views