[英]Errors when sending data in body using Finagle/Finch in Scala
我正在使用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")
}
我不知道該如何解決。
body
API在Finch 0.11中進行了更改。 只需將您的body
調用更改為body[CT, Foo]
(其中CT
是內容類型),就應該對其進行編譯。 一件事: String
主體是一種特殊情況,因此您可能要使用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"})
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.