2017-04-20 44 views
0

我使用Finagle/Finch和我得到這個錯誤:錯誤Scala中發送使用欺騙/芬奇體數據時

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") 
    } 

我不知道如何解決這個。

回答

2

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"}) 
+0

謝謝。刪除一個庫並更新後,對我的模型進行更改後,我將其編譯。 :) –