1 module Gargantext.API.HashedResponse where
5 import Data.Text (Text)
6 import Gargantext.Prelude
7 import qualified Gargantext.Prelude.Utils as Crypto (hash)
8 import GHC.Generics (Generic)
10 data HashedResponse a = HashedResponse { hash :: 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 (Crypto.hash $ encode v) v