aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2016-01-20 10:22:51 +0000
committerGregor Kleen <gkleen@yggdrasil.li>2016-01-20 10:22:51 +0000
commit1b598d96cafa99da25609125da71d31fbab361bb (patch)
treedc4a21512830e264f8e8c635c79c73f7c8076bc5
parente13e08c31a2816a15ab10c078fd3adeb7abb83d7 (diff)
downloadthermoprint-1b598d96cafa99da25609125da71d31fbab361bb.tar
thermoprint-1b598d96cafa99da25609125da71d31fbab361bb.tar.gz
thermoprint-1b598d96cafa99da25609125da71d31fbab361bb.tar.bz2
thermoprint-1b598d96cafa99da25609125da71d31fbab361bb.tar.xz
thermoprint-1b598d96cafa99da25609125da71d31fbab361bb.zip
Extended server skeleton up to servant-server
-rw-r--r--server/src/Thermoprint/Server.hs22
-rw-r--r--server/thermoprint-server.cabal5
-rw-r--r--server/thermoprint-server.nix6
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
1module Thermoprint.Server 3module Thermoprint.Server
2 ( thermoprintServer 4 ( thermoprintServer
3 , module Data.Default 5 , module Data.Default.Class
4 ) where 6 ) where
5 7
6import Data.Default 8import Data.Default.Class
7import qualified Config.Dyre as Dyre 9import qualified Config.Dyre as Dyre
8 10
9import System.IO (hPutStrLn, stderr) 11import System.IO (hPutStrLn, stderr)
@@ -11,11 +13,20 @@ import System.Exit (exitFailure)
11 13
12import Control.Monad ((<=<)) 14import Control.Monad ((<=<))
13 15
14data Config = Config { dyreError :: Maybe String 16import qualified Network.Wai.Handler.Warp as Warp
17import Network.Wai (Application)
18
19import Servant.Server
20
21import Thermoprint.API
22
23data Config = Config { dyreError :: Maybe String
24 , warpSettings :: Warp.Settings
15 } 25 }
16 26
17instance Default Config where 27instance Default Config where
18 def = Config { dyreError = Nothing 28 def = Config { dyreError = Nothing
29 , warpSettings = Warp.defaultSettings
19 } 30 }
20 31
21thermoprintServer :: Config -> IO () 32thermoprintServer :: Config -> IO ()
@@ -35,4 +46,7 @@ handleDyreErrors cfg
35 46
36 47
37realMain :: Config -> IO () 48realMain :: Config -> IO ()
38realMain _ = undefined 49realMain cfg@(Config{..}) = Warp.runSettings warpSettings $ serve thermoprintAPI thermoprintServer'
50
51thermoprintServer :: Server ThermoprintAPI
52thermoprintServer = 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}:
3mkDerivation { 4mkDerivation {
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";