REST API возвращает пустой ответ в Ktor - PullRequest
0 голосов
/ 28 марта 2019

Я использую Ktor в моем классе Koltin / Java после запроса среды Netty.

Мой текущий класс WebServer.kt выглядит следующим образом:

fun init(serviceProperties: ServerProperties) {

    val route = Routing(serviceProperties)

    val env = applicationEngineEnvironment {
        module {
            main()
        }

        connector {
            host = route.getInternalAddress()
            port = route.getPort()
        }

        connector {
            host = route.getExternalAddress()
            port = route.getPort()
        }
    }

    embeddedServer(Netty, env)
        .start(wait = true)
}

Мой метод для обработки всех запросов выглядит следующим образом:

private fun Application.main() {
    install(CORS)
    routing {
        get("/") {
            call.respondText ("Test", ContentType.Text.Plain)
        }
    }
}

Дополнительная информация:

route.getInternalAddress() // 192.168.0.18 <-- (IPV4 IP) trying to test
route.getExternalAddress() // 0.0.0.0 <-- not yet needed
route.getPort() // 8080

Мой вывод выглядит следующим образом:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by io.netty.util.internal.PlatformDependent0 (file:/C:/Users/Kye/.gradle/caches/modules-2/files-2.1/io.netty/netty-all/4.0.34.Final/e1e53fb0283cc6fbc0f3631e60f658ddebcf005/netty-all-4.0.34.Final.jar) to field java.nio.Buffer.address
WARNING: Please consider reporting this to the maintainers of io.netty.util.internal.PlatformDependent0
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[19:18:46.084 INFO ] Application          | No ktor.deployment.watch patterns specified, automatic reload is not active
[19:18:46.256 INFO ] Application          | Responding at http://192.168.0.18:8080
[19:18:46.256 INFO ] Application          | Responding at http://0.0.0.0:8080

Когда яна http://192.168.0.18:8080/ я получаю

192.168.0.18 не отправил никаких данныхERR_EMPTY_RESPONSE

Что я делаю не так?

...