1 module Gargantext.API.HashedResponse where
5 import qualified Data.Digest.Pure.MD5 as DPMD5
6 import GHC.Generics (Generic)
9 data HashedResponse a = HashedResponse { md5 :: Text, value :: a }
12 instance ToSchema a => ToSchema (HashedResponse a)
13 instance ToJSON a => ToJSON (HashedResponse a) where
14 toJSON = genericToJSON defaultOptions
16 constructHashedResponse :: ToJSON a => a -> HashedResponse a
17 constructHashedResponse v = HashedResponse { md5 = md5', value = v }
19 md5' = show $ DPMD5.md5 $ encode v