0

我正在使用Finagle/Finch并收到此错误:

diverging implicit expansion for type argonaut.DecodeJson[A] starting 
  with method MapDecodeJson in trait DecodeJsons
diverging implicit expansion for type argonaut.DecodeJson[V] starting 
  with method MapDecodeJson in trait DecodeJsons
not enough arguments for method body: (implicit d: 
 io.finch.Decode.Aux[A,CT], implicit ct: 
 scala.reflect.ClassTag[A])io.finch.Endpoint[A]. Unspecified value 
 parameters d, ct.

对于此代码:

def sendPost(db: CommDb): Endpoint[String] =
  post("posts" :: body.as[String]) { s: String =>
    Ok("success")
  }

我不知道如何解决这个问题。

4

1 回答 1

2

bodyAPI 在Finch 0.11中发生了变化。只需将您的body调用更改为body[CT, Foo]CT内容类型在哪里),您就应该编译它。一件事:Stringbody 是一种特殊情况,因此您可能希望使用stringBody(无类型参数),因为body它倾向于使用给定的 JSON/XML/任何解码器解码有效负载。

scala> import io.finch._, io.finch.circe._

scala> s(Input.post("/").withBody[Application.Json](Map("foo" -> "bar"))).awaitValueUnsafe()
res2: Option[String] = Some({"foo":"bar"})
于 2017-04-21T17:49:48.253 回答