我是 Kotlin 和 Ktor 的新手,所以我尝试做简单的发布请求。正如你在下面看到的,没有什么特别的。
routing {
post("/articles/add"){
val post = call.receive<ArticleRequest>()
println(post)
}
Run Code Online (Sandbox Code Playgroud)
日志中显示的错误如下,我不明白为什么我应该在这里使用协程。
ERROR Application - Unhandled: POST - /articles/add
java.lang.IllegalStateException: Using blocking primitives on this dispatcher is not allowed. Consider using async channel instead or use blocking primitives in withContext(Dispatchers.IO) instead.
Run Code Online (Sandbox Code Playgroud)
我正在使用 1.4.2 版本。我将不胜感激任何帮助。