1 {-# OPTIONS_GHC -fprint-potential-instances #-}
3 module Gargantext.API.Types where
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
12 import Network.HTTP.Media ((//), (/:))
14 import qualified Prelude
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