私HttpServiceはjsonを受け取り、それをjson4sライブラリでケースクラスに解析することを定義しようとしています:
import org.http4s._
import org.http4s.dsl._
import org.json4s._
import org.json4s.native.JsonMethods._
case class Request(firstName: String, secondName: String)
HttpService {
case req @ POST -> Root =>
val request = parse(<map req.body or req.bodyAsText to JsonInput>).extract[Request]
Ok()
}
org.json4s.JsonInputまたはからどのように取得できますreq.bodyかreq.bodyAsText?
私はまた、 with を使用するために継承することを知っているjson4sので、toまたはStringInputtoに変換する必要があると思いますが、まだ方法がわかりません。StreamInputJsonInputStringInputStreamreq.bodyInputStreamreq.bodyAsTextString
私は Scala を初めて使用し、 などのいくつかの概念をまだ完全には理解していませんscalaz.stream.Process。