diff options
| -rw-r--r-- | server/src/Thermoprint/Server.hs | 22 | ||||
| -rw-r--r-- | server/thermoprint-server.cabal | 5 | ||||
| -rw-r--r-- | server/thermoprint-server.nix | 6 |
3 files changed, 26 insertions, 7 deletions
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 @@ | |||
| 1 | {-# LANGUAGE RecordWildCards #-} | ||
| 2 | |||
| 1 | module Thermoprint.Server | 3 | module Thermoprint.Server |
| 2 | ( thermoprintServer | 4 | ( thermoprintServer |
| 3 | , module Data.Default | 5 | , module Data.Default.Class |
| 4 | ) where | 6 | ) where |
| 5 | 7 | ||
| 6 | import Data.Default | 8 | import Data.Default.Class |
| 7 | import qualified Config.Dyre as Dyre | 9 | import qualified Config.Dyre as Dyre |
| 8 | 10 | ||
| 9 | import System.IO (hPutStrLn, stderr) | 11 | import System.IO (hPutStrLn, stderr) |
| @@ -11,11 +13,20 @@ import System.Exit (exitFailure) | |||
| 11 | 13 | ||
| 12 | import Control.Monad ((<=<)) | 14 | import Control.Monad ((<=<)) |
| 13 | 15 | ||
| 14 | data Config = Config { dyreError :: Maybe String | 16 | import qualified Network.Wai.Handler.Warp as Warp |
| 17 | import Network.Wai (Application) | ||
| 18 | |||
| 19 | import Servant.Server | ||
| 20 | |||
| 21 | import Thermoprint.API | ||
| 22 | |||
| 23 | data Config = Config { dyreError :: Maybe String | ||
| 24 | , warpSettings :: Warp.Settings | ||
| 15 | } | 25 | } |
| 16 | 26 | ||
| 17 | instance Default Config where | 27 | instance Default Config where |
| 18 | def = Config { dyreError = Nothing | 28 | def = Config { dyreError = Nothing |
| 29 | , warpSettings = Warp.defaultSettings | ||
| 19 | } | 30 | } |
| 20 | 31 | ||
| 21 | thermoprintServer :: Config -> IO () | 32 | thermoprintServer :: Config -> IO () |
| @@ -35,4 +46,7 @@ handleDyreErrors cfg | |||
| 35 | 46 | ||
| 36 | 47 | ||
| 37 | realMain :: Config -> IO () | 48 | realMain :: Config -> IO () |
| 38 | realMain _ = undefined | 49 | realMain cfg@(Config{..}) = Warp.runSettings warpSettings $ serve thermoprintAPI thermoprintServer' |
| 50 | |||
| 51 | thermoprintServer :: Server ThermoprintAPI | ||
| 52 | thermoprintServer = undefined | ||
diff --git a/server/thermoprint-server.cabal b/server/thermoprint-server.cabal index cd23251..c8586ae 100644 --- a/server/thermoprint-server.cabal +++ b/server/thermoprint-server.cabal | |||
| @@ -23,6 +23,9 @@ executable thermoprint-server | |||
| 23 | build-depends: base >=4.8 && <4.9 | 23 | build-depends: base >=4.8 && <4.9 |
| 24 | , thermoprint-spec ==3.0.* | 24 | , thermoprint-spec ==3.0.* |
| 25 | , dyre >=0.8.12 && <1 | 25 | , dyre >=0.8.12 && <1 |
| 26 | , data-default -any | 26 | , data-default-class >=0.0.1 && <1 |
| 27 | , wai >=3.0.4 && <4 | ||
| 28 | , servant-server >=0.4.4 && <1 | ||
| 29 | , warp >=3.1.9 && <4 | ||
| 27 | hs-source-dirs: src | 30 | hs-source-dirs: src |
| 28 | default-language: Haskell2010 \ No newline at end of file | 31 | default-language: Haskell2010 \ No newline at end of file |
diff --git a/server/thermoprint-server.nix b/server/thermoprint-server.nix index 4f61c49..7154dc3 100644 --- a/server/thermoprint-server.nix +++ b/server/thermoprint-server.nix | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | { mkDerivation, base, data-default, dyre, stdenv, thermoprint-spec | 1 | { mkDerivation, base, data-default-class, dyre, servant-server |
| 2 | , stdenv, thermoprint-spec, wai, warp | ||
| 2 | }: | 3 | }: |
| 3 | mkDerivation { | 4 | mkDerivation { |
| 4 | pname = "thermoprint-server"; | 5 | pname = "thermoprint-server"; |
| @@ -7,7 +8,8 @@ mkDerivation { | |||
| 7 | isLibrary = false; | 8 | isLibrary = false; |
| 8 | isExecutable = true; | 9 | isExecutable = true; |
| 9 | executableHaskellDepends = [ | 10 | executableHaskellDepends = [ |
| 10 | base data-default dyre thermoprint-spec | 11 | base data-default-class dyre servant-server thermoprint-spec wai |
| 12 | warp | ||
| 11 | ]; | 13 | ]; |
| 12 | homepage = "http://dirty-haskell.org/tags/thermoprint.html"; | 14 | homepage = "http://dirty-haskell.org/tags/thermoprint.html"; |
| 13 | description = "Server for thermoprint-spec"; | 15 | description = "Server for thermoprint-spec"; |
