1 module Gargantext.API.HashedResponse where
5 import Data.Text (Text)
6 import Gargantext.Prelude
7 import Gargantext.Prelude.Utils (hash)
8 import GHC.Generics (Generic)
10 data HashedResponse a = HashedResponse { md5 :: Text, value :: a }
13 instance ToSchema a => ToSchema (HashedResponse a)
14 instance ToJSON a => ToJSON (HashedResponse a) where
15 toJSON = genericToJSON defaultOptions
17 constructHashedResponse :: ToJSON a => a -> HashedResponse a
18 constructHashedResponse v = HashedResponse { md5 = md5', value = v }
20 md5' = hash $ encode v