]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/API/Types.hs
improve performance of logDistributional, upgrade to accelerate 1.3 + lots of debug...
[gargantext.git] / src / Gargantext / API / Types.hs
1 {-# OPTIONS_GHC -fprint-potential-instances #-}
2
3 module Gargantext.API.Types where
4
5 import Data.Aeson
6 import qualified Data.ByteString.Lazy.Char8 as BS8
7 import Data.Either (Either(..))
8 import Data.List.NonEmpty (NonEmpty ((:|)))
9 import Data.Text (Text)
10 import qualified Data.Text.Encoding as E
11 import Data.Typeable
12 import Network.HTTP.Media ((//), (/:))
13 import Prelude (($))
14 import qualified Prelude
15 import Servant
16 ( Accept(..)
17 , MimeRender(..)
18 , MimeUnrender(..) )
19
20 data HTML deriving (Typeable)
21 instance Accept HTML where
22 contentTypes _ = "text" // "html" /: ("charset", "utf-8") :| ["text" // "html"]
23 instance MimeRender HTML BS8.ByteString where
24 mimeRender _ = Prelude.id
25 instance MimeUnrender HTML BS8.ByteString where
26 mimeUnrender _ bs = Right bs
27 instance MimeRender HTML Text where
28 mimeRender _ bs = BS8.fromStrict $ E.encodeUtf8 bs
29 instance MimeUnrender HTML Text where
30 mimeUnrender _ bs = Right $ E.decodeUtf8 $ BS8.toStrict bs
31 instance {-# OVERLAPPABLE #-} ToJSON a => MimeRender HTML a where
32 mimeRender _ = encode