我试图执行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)
}
}
}注意类:
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()我所有的POST请求都正常工作,但这个GET请求不起作用。
发布于 2021-06-02 11:47:07
ktor docs的authentication插件给出了以不同于您指定的方式布局路由器的示例。示例代码:
routing {
authenticate("myauth1") {
get("/authenticated/route1") {
...但是,在您的代码中传递的路由如下:
route("/getNotes") {
authenticate {
get {
...您是否可以尝试在get而不是route中指定路由
https://stackoverflow.com/questions/67504961
复制相似问题