1 module Gargantext.API.HashedResponse where
5 import Data.Text (Text)
7 import Gargantext.Prelude
8 import qualified Gargantext.Core.Crypto.Hash as Crypto (hash)
9 import GHC.Generics (Generic)
11 data HashedResponse a = HashedResponse { hash :: Text, value :: a }
14 instance ToSchema a => ToSchema (HashedResponse a)
15 instance ToJSON a => ToJSON (HashedResponse a) where
16 toJSON = genericToJSON defaultOptions
18 constructHashedResponse :: ToJSON a => a -> HashedResponse a
19 constructHashedResponse v = HashedResponse { hash = Crypto.hash $ encode v, value = v }