This tut shows how to create an http4s Request: https://http4s.org/v0.18/dsl/#testing-the-service
I would like to change this request to a POST method and add a literal json body using circe. I tried the following code:
val body = json"""{"hello":"world"}"""
val req = Request[IO](method = Method.POST, uri = Uri.uri("/"), body = body)
This gives me a type mismatch error:
[error] found : io.circe.Json
[error] required: org.http4s.EntityBody[cats.effect.IO]
[error] (which expands to) fs2.Stream[cats.effect.IO,Byte]
[error] val entity: EntityBody[IO] = body
I understand the error, but I cannot figure out how to convert io.circe.Json
into an EntityBody
. Most examples I have seen use an EntityEncoder
, which does not provide the required type.
How can I convert io.circe.Json
into an EntityBody
?
EntityEncoder
s to create acats.effect.IO[org.http4s.Entity[cats.effect.IO]]
type. – Mosier