From 1b598d96cafa99da25609125da71d31fbab361bb Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Wed, 20 Jan 2016 10:22:51 +0000 Subject: Extended server skeleton up to servant-server --- server/src/Thermoprint/Server.hs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'server/src') diff --git a/server/src/Thermoprint/Server.hs b/server/src/Thermoprint/Server.hs index bba067d..9b8d719 100644 --- a/server/src/Thermoprint/Server.hs +++ b/server/src/Thermoprint/Server.hs @@ -1,9 +1,11 @@ +{-# LANGUAGE RecordWildCards #-} + module Thermoprint.Server ( thermoprintServer - , module Data.Default + , module Data.Default.Class ) where -import Data.Default +import Data.Default.Class import qualified Config.Dyre as Dyre import System.IO (hPutStrLn, stderr) @@ -11,11 +13,20 @@ import System.Exit (exitFailure) import Control.Monad ((<=<)) -data Config = Config { dyreError :: Maybe String +import qualified Network.Wai.Handler.Warp as Warp +import Network.Wai (Application) + +import Servant.Server + +import Thermoprint.API + +data Config = Config { dyreError :: Maybe String + , warpSettings :: Warp.Settings } instance Default Config where def = Config { dyreError = Nothing + , warpSettings = Warp.defaultSettings } thermoprintServer :: Config -> IO () @@ -35,4 +46,7 @@ handleDyreErrors cfg realMain :: Config -> IO () -realMain _ = undefined +realMain cfg@(Config{..}) = Warp.runSettings warpSettings $ serve thermoprintAPI thermoprintServer' + +thermoprintServer :: Server ThermoprintAPI +thermoprintServer = undefined -- cgit v1.2.3