summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cgserver.cabal1
-rw-r--r--cgserver.nix5
-rw-r--r--src/Main.hs13
-rw-r--r--src/Main/Config.hs1
4 files changed, 14 insertions, 6 deletions
diff --git a/cgserver.cabal b/cgserver.cabal
index 611315a..5b4ef50 100644
--- a/cgserver.cabal
+++ b/cgserver.cabal
@@ -27,6 +27,7 @@ executable cgserver
, safe >=0.3 && <0.4
, text >=1.1 && <1.3
, wai >=3.0 && <3.1
+ , wai-extra >= 3.0 && <3.1
, warp >=3.0 && <3.1
hs-source-dirs: src
default-language: Haskell2010
diff --git a/cgserver.nix b/cgserver.nix
index 840531c..bd8d12b 100644
--- a/cgserver.nix
+++ b/cgserver.nix
@@ -1,7 +1,7 @@
# This file was auto-generated by cabal2nix. Please do NOT edit manually!
{ cabal, aeson, attoparsec, filepath, httpTypes, ioStreams, safe
-, text, wai, warp
+, text, wai, waiExtra, warp
}:
cabal.mkDerivation (self: {
@@ -11,7 +11,8 @@ cabal.mkDerivation (self: {
isLibrary = false;
isExecutable = true;
buildDepends = [
- aeson attoparsec filepath httpTypes ioStreams safe text wai warp
+ aeson attoparsec filepath httpTypes ioStreams safe text wai
+ waiExtra warp
];
meta = {
license = self.stdenv.lib.licenses.bsd3;
diff --git a/src/Main.hs b/src/Main.hs
index a2755e0..ef7710f 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -48,10 +48,12 @@ import Data.Attoparsec.ByteString.Char8 (decimal, endOfInput, parseOnly)
import qualified Data.ByteString.Char8 as BS8
import qualified Data.ByteString.Lazy as LBS
import Data.List (isInfixOf)
+import Data.Monoid
import Main.Config
import Main.Util
-import Network.Wai.Handler.Warp (run)
import Network.Wai
+import Network.Wai.Handler.Warp (run)
+import Network.Wai.Middleware.RequestLogger (logStdout)
import System.FilePath
import System.IO.Error
@@ -75,9 +77,12 @@ main =
-- | Run the application with the given configuration.
start :: Config -> IO ()
-start c =
- run (httpPort c) $ \req ->
- resourceHandler (requestResource c req) req
+start c = do
+ putStrLn $ "run cgserver with " <> show c
+ run (httpPort c)
+ $ logStdout
+ $ \req ->
+ resourceHandler (requestResource c req) req
-- | Determine which request is requested.
diff --git a/src/Main/Config.hs b/src/Main/Config.hs
index 45fa50f..9639faa 100644
--- a/src/Main/Config.hs
+++ b/src/Main/Config.hs
@@ -22,6 +22,7 @@ data Config = Config
{ cgroupRoot :: FilePath
, httpPort :: Port
}
+ deriving Show
-- |