From 03025c105e5fb3055e57e2df9d2af258d579ff7f Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 9 Mar 2017 21:58:34 +0100 Subject: Configure warp --- bragi/thermoprint-server/thermoprint-server.hs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'bragi') diff --git a/bragi/thermoprint-server/thermoprint-server.hs b/bragi/thermoprint-server/thermoprint-server.hs index 6142e7d9..97b37374 100644 --- a/bragi/thermoprint-server/thermoprint-server.hs +++ b/bragi/thermoprint-server/thermoprint-server.hs @@ -1,5 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ImpredicativeTypes #-} +{-# LANGUAGE RecordWildCards #-} module Main (main) where @@ -11,19 +12,22 @@ import Control.Monad.Trans.Resource import Control.Monad.Logger import Control.Monad.Reader +import Data.Function ((&)) + import Database.Persist.Postgresql +import qualified Network.Wai.Handler.Warp as Warp + type ServerM = ReaderT ConnectionPool (LoggingT IO) main :: IO () -main = thermoprintServer True (Nat runDb) $ (\c -> c { queueManagers = queueManagers }) <$> def `withPrinters` printers +main = thermoprintServer True (Nat runDb) $ configure (\c -> c{..}) <$> def `withPrinters` printers' where runDb :: ServerM a -> IO a runDb = runStderrLoggingT . withPostgresqlPool "" 5 . runReaderT - printers :: [(ResourceT ServerM PrinterMethod, QMConfig (ResourceT ServerM))] - printers = [ (pure $ genericPrint "/dev/usb/lp0", def) - ] + printers' = [ (pure $ genericPrint "/dev/usb/lp0", def :: QMConfig (ResourceT ServerM)) + ] queueManagers _ = QMConfig { manager = union [ limitHistorySize 100 @@ -31,3 +35,7 @@ main = thermoprintServer True (Nat runDb) $ (\c -> c { queueManagers = queueMana ] , collapse = standardCollapse } + + warpSettings = Warp.defaultSettings + & Warp.setHost "localhost" + & Warp.setPort 8080 -- cgit v1.2.3