Web 执行GET请求时出错(未处理:GET)

Web 执行GET请求时出错(未处理:GET),web,backend,ktor,Web,Backend,Ktor,我试图执行GET请求,但出现了此错误 这里的Bug很明显,但我不知道是什么问题 suspend fun getNotesForUser(email: String) = notes.find(Note::owners contains email).toList() 这是路线代码 route("/getNotes") { authenticate { get { val email = call.principal<U

我试图执行GET请求,但出现了此错误

这里的Bug很明显,但我不知道是什么问题

suspend fun getNotesForUser(email: String) = notes.find(Note::owners contains email).toList()
这是路线代码

route("/getNotes") {
    authenticate {
        get {
            val email = call.principal<UserIdPrincipal>()!!.name
            val notes = getNotesForUser(email)
            call.respond(OK, notes)
        }
    }
}
route(“/getNotes”){
鉴定{
得到{
val email=call.principal()!!.name
val notes=getNotesForUser(电子邮件)
打电话。回复(好,注意事项)
}
}
}
注:类别:

data class Note(
val title: String,
val content: String,
val date: Long,
val owners: List<String>,
val color: String,
@BsonId
val id: String = ObjectId().toString()
数据类注释(
val标题:字符串,
val内容:字符串,
val日期:长,
val所有者:列表,
val颜色:字符串,
@BsonId
val id:String=ObjectId().toString()

我所有的POST请求都能正常工作,但这一个GET不能正常工作。

ktor的
身份验证插件给出了以不同于您指定的方式布置路由器的示例。示例代码:

routing {
    authenticate("myauth1") {
        get("/authenticated/route1") {
...
但是,在代码中,您通过以下路径传递:

route("/getNotes") {
    authenticate {
        get {
...
您是否可以尝试在
get
中而不是在
route
中指定路线的方法