我收到此错误:
Cannot decode into a value of type com.blah.rest.model.UserProfile,
because no EntityDecoder[cats.effect.IO, com.blah.rest.model.UserProfile]
instance could be found.
对于以下案例类:
case class UserProfile(id: Option[Int], firstName: String, lastName: String)
遇到POST
代码错误:
case req @ POST -> Root / "v1" / "profiles" =>
req.as[UserProfile] flatMap {(up: UserProfile) =>
Ok(service.createProfile(up).asJson)
}
具有以下POST
主体:
{
"firstName": "Jack",
"lastName": "Appleseed"
}
我认为当身体被转换为时会发生这种UserProfile
情况req.as[UserProfile]
!
但是,这是一个普通的案例类,EntityDecoder
应该是自动派生的!我知道akka-http
会!
有什么想法/建议吗?
请注意: Http4sVersion = "0.18.0-M4"
和circe version "0.9.0-M1"