diff options
Diffstat (limited to 'servant/api')
| -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] () | ||
