【发布时间】:2019-12-18 00:26:22
【问题描述】:
我正在学习如何使用 ktor。对于特殊用例,我需要从我的 ktor 服务器重定向到不同的域。但是我现在不能让它正常工作。
作为一个简单的例子,我有一个 Application.kt
import io.ktor.application.*
import io.ktor.http.*
import io.ktor.response.*
import io.ktor.routing.*
import io.ktor.server.engine.*
import io.ktor.server.netty.*
fun main(args: Array<String>) {
val server = embeddedServer(Netty, port = 8080) {
routing {
get("/") {
call.respondRedirect("www.google.com")
}}
}
}
server.start(wait = true)
}
除了它将我重定向到www.google.com之外,它会将我重定向到localhost:8080/www.google.com
【问题讨论】: