aboutsummaryrefslogtreecommitdiff
path: root/servant/api
diff options
context:
space:
mode:
Diffstat (limited to 'servant/api')
-rw-r--r--servant/api/Thermoprint/Api.hs28
1 files changed, 28 insertions, 0 deletions
diff --git a/servant/api/Thermoprint/Api.hs b/servant/api/Thermoprint/Api.hs
new file mode 100644
index 0000000..bd5744b
--- /dev/null
+++ b/servant/api/Thermoprint/Api.hs
@@ -0,0 +1,28 @@
1{-# LANGUAGE DataKinds, TypeOperators, DeriveGeneric #-}
2
3module Thermoprint.Api
4 ( ThermoprintApi
5 ) where
6
7import Thermoprint
8import Data.Aeson
9import Servant.API
10import qualified Data.Text.Lazy as Text
11import qualified Data.ByteString.Lazy.Char8 as ByteString
12import Data.ByteString.Lazy.Char8 (ByteString)
13import GHC.Generics
14
15import Control.Monad
16
17instance ToJSON ByteString where
18 toJSON = toJSON . Text.pack . ByteString.unpack
19instance FromJSON ByteString where
20 parseJSON value = (ByteString.pack . Text.unpack) `liftM` parseJSON value
21
22instance ToJSON c => ToJSON (Inline c)
23instance FromJSON c => FromJSON (Inline c)
24
25instance ToJSON c => ToJSON (Block c)
26instance FromJSON c => FromJSON (Block c)
27
28type ThermoprintApi = "print" :> Capture "printerId" Integer :> ReqBody '[JSON] (Block String) :> Post '[JSON] ()