I'm trying to marshal an akka HttpResponse
as such:
{
"code": 200,
"headers": [],
"body": "{\"data\": \"Yes!\"}"
}
If I write an Argonaut EncodeJson
for this Instance, it might look like this:
implicit def httpResponseEncodeJson: EncodeJson[HttpResponse] =
EncodeJson(
(res: HttpResponse) ⇒ {
("code" := res._1.value) ->:
("headers" := res._2.toList) ->:
("body" := res._3) ->: jEmptyObject
}
)
I have managed to marshal the headers as json. The only problem is with the body, i.e.,
the ResponseEntity
. Since it is an akka stream, it can only return a future, if I use .toStrict
.
Can anybody guide me as to how I might marshal it?