data Result
= forall j. ToJSON j => Value j
| Bytes { contentType :: BS.ByteString, body :: LBS.ByteString }
| Error { statusCode :: Int, errorMessage :: LBS.ByteString }
| Empty
\case
Value json -> responseLBS
(toEnum 200)
[("content-type", "application/activity+json")]
(encode json)
Bytes contentType body -> responseLBS
(toEnum 200)
[("content-type", contentType)]
body
Error code body -> responseLBS
(toEnum code)
[("content-type", "application/json")]
(encode $ object [ "error" .= T.decodeUtf8 (BS.toStrict body) ])
Empty -> responseLBS (toEnum 202) [] ""
\case
Bytes _ _ -> 200
Empty -> 202
Error code _ -> code
Value _ -> 200