diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2015-10-17 02:26:25 +0200 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2015-10-17 02:26:25 +0200 |
commit | 005dc408dc09c3b479398ebe3e92efa2cd54846e (patch) | |
tree | 23dcfe7a545885c9aa145f1ccae6d33206a87820 /servant/api/Thermoprint | |
parent | 2dcbb4482de2c352b76372b389fda20c63075295 (diff) | |
download | thermoprint-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')
-rw-r--r-- | servant/api/Thermoprint/Api.hs | 28 |
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 | |||
3 | module Thermoprint.Api | ||
4 | ( ThermoprintApi | ||
5 | ) where | ||
6 | |||
7 | import Thermoprint | ||
8 | import Data.Aeson | ||
9 | import Servant.API | ||
10 | import qualified Data.Text.Lazy as Text | ||
11 | import qualified Data.ByteString.Lazy.Char8 as ByteString | ||
12 | import Data.ByteString.Lazy.Char8 (ByteString) | ||
13 | import GHC.Generics | ||
14 | |||
15 | import Control.Monad | ||
16 | |||
17 | instance ToJSON ByteString where | ||
18 | toJSON = toJSON . Text.pack . ByteString.unpack | ||
19 | instance FromJSON ByteString where | ||
20 | parseJSON value = (ByteString.pack . Text.unpack) `liftM` parseJSON value | ||
21 | |||
22 | instance ToJSON c => ToJSON (Inline c) | ||
23 | instance FromJSON c => FromJSON (Inline c) | ||
24 | |||
25 | instance ToJSON c => ToJSON (Block c) | ||
26 | instance FromJSON c => FromJSON (Block c) | ||
27 | |||
28 | type ThermoprintApi = "print" :> Capture "printerId" Integer :> ReqBody '[JSON] (Block String) :> Post '[JSON] () | ||