变量call属性从哪里来?

Where does the variable call property come from?

我正在尝试使用 Ktor routing,我想弄清楚以下代码的工作原理:

application.install(Routing) {
        get("/") {
            call.respondText("Hello, World!")
        }
        get("/bye") {
            call.respondText("Good bye, World!")
        }
    }

变量call属性从何而来?我看了 https://api.ktor.io/1.4.0/io.ktor.routing/-route/index.html 但没弄明白。

我知道get的第二个参数:

get("/bye") {
                call.respondText("Good bye, World!")
            }

需要 lambda。但是 call 变量必须进入范围。不明确。

callPipelineContext 的扩展变量 (getter),正如您提到的,它是 get 方法的第二个参数接收者。

inline val PipelineContext<*, ApplicationCall>.call: ApplicationCall get() = context

阅读更多关于extensions