我試圖封送阿卡HttpResponse
這樣:元帥阿卡`HttpResponse`作爲淘金者'Json`
{
"code": 200,
"headers": [],
"body": "{\"data\": \"Yes!\"}"
}
如果我寫的淘金EncodeJson
對於這種情況下,它可能是這樣的:
implicit def httpResponseEncodeJson: EncodeJson[HttpResponse] =
EncodeJson(
(res: HttpResponse) ⇒ {
("code" := res._1.value) ->:
("headers" := res._2.toList) ->:
("body" := res._3) ->: jEmptyObject
}
)
我設法將頭部編組爲json。唯一的問題是身體,即 ResponseEntity
。由於它是一個阿克卡流,如果我使用.toStrict
,它只能返回未來。
任何人都可以指導我如何編組嗎?
非常感謝您的回答。我認爲我做了幾乎相同的事情。你能回顧我的答案嗎? –