aboutsummaryrefslogtreecommitdiff
path: root/servant/api/Thermoprint/Api.hs
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2015-10-17 02:26:25 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2015-10-17 02:26:25 +0200
commit005dc408dc09c3b479398ebe3e92efa2cd54846e (patch)
tree23dcfe7a545885c9aa145f1ccae6d33206a87820 /servant/api/Thermoprint/Api.hs
parent2dcbb4482de2c352b76372b389fda20c63075295 (diff)
downloadthermoprint-005dc408dc09c3b479398ebe3e92efa2cd54846e.tar
thermoprint-005dc408dc09c3b479398ebe3e92efa2cd54846e.tar.gz
thermoprint-005dc408dc09c3b479398ebe3e92efa2cd54846e.tar.bz2
thermoprint-005dc408dc09c3b479398ebe3e92efa2cd54846e.tar.xz
thermoprint-005dc408dc09c3b479398ebe3e92efa2cd54846e.zip
Working prototype
Diffstat (limited to 'servant/api/Thermoprint/Api.hs')
-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] ()