import Data.Aeson
import Data.Swagger
import Data.Text (Text)
+import GHC.Generics (Generic)
import Gargantext.Prelude
-import qualified Gargantext.Core.Crypto.Hash as Crypto (hash)
-import GHC.Generics (Generic)
+import qualified Gargantext.Prelude.Crypto.Hash as Crypto (hash)
data HashedResponse a = HashedResponse { hash :: Text, value :: a }
deriving (Generic)
instance ToSchema a => ToSchema (HashedResponse a)
instance ToJSON a => ToJSON (HashedResponse a) where
toJSON = genericToJSON defaultOptions
+instance FromJSON a => FromJSON (HashedResponse a) where
+ parseJSON = genericParseJSON defaultOptions
constructHashedResponse :: ToJSON a => a -> HashedResponse a
constructHashedResponse v = HashedResponse { hash = Crypto.hash $ encode v, value = v }