2 Module : Gargantext.API.HashedResponse
4 Copyright : (c) CNRS, 2020-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
12 module Gargantext.API.HashedResponse where
16 import Data.Text (Text)
17 import GHC.Generics (Generic)
19 import Gargantext.Prelude
20 import qualified Gargantext.Core.Crypto.Hash as Crypto (hash)
22 data HashedResponse a = HashedResponse { hash :: Text, value :: a }
25 instance ToSchema a => ToSchema (HashedResponse a)
26 instance ToJSON a => ToJSON (HashedResponse a) where
27 toJSON = genericToJSON defaultOptions
29 constructHashedResponse :: ToJSON a => a -> HashedResponse a
30 constructHashedResponse v = HashedResponse { hash = Crypto.hash $ encode v, value = v }