maid 2009.7.24 → 2009.7.24.1
raw patch · 3 files changed
+36/−12 lines, 3 filesdep +data-defaultdep +hack-contribdep +hack-handler-happstackdep −hack-handler-simpleserver
Dependencies added: data-default, hack-contrib, hack-handler-happstack
Dependencies removed: hack-handler-simpleserver
Files
- changelog.md +8/−0
- maid.cabal +2/−2
- src/maid.hs +26/−10
changelog.md view
@@ -1,3 +1,11 @@+2009.7.24.1+-----------++### Feature++* Use happstack backend for better error handling+* add simple logger+ 2009.7.24 ---------
maid.cabal view
@@ -1,5 +1,5 @@ Name: maid-Version: 2009.7.24+Version: 2009.7.24.1 Build-type: Simple Synopsis: A simple static web server Description:@@ -18,6 +18,6 @@ Executable maid ghc-options: -Wall- build-depends: base >= 4 && < 5, mps, loli, hack-handler-simpleserver, haskell98+ build-depends: base >= 4 && < 5, mps, loli, hack-handler-happstack, haskell98, hack-contrib, data-default hs-source-dirs: src/ main-is: maid.hs
src/maid.hs view
@@ -1,12 +1,14 @@ {-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE NamedFieldPuns #-} -import Network.Loli-import Hack.Handler.SimpleServer-import System-import MPS.TH-import MPS.Light (splash, tuple2, reject)-import MPS (strip)+import Network.Loli (loli, public, mime)+import Hack.Handler.Happstack (runWithConfig, port)+import System (getArgs)+import MPS.TH (here)+import MPS (splash, tuple2, reject, strip, format_time, now) import Control.Arrow ((>>>))+import Data.Default (def)+import Hack.Contrib.Request (url) main :: IO () main = do@@ -17,11 +19,25 @@ else read $ head args } - putStrLn $ "\n \226\157\130 Maid serving on port: " ++ show port+ let { app =+ log_access $ loli $ do+ public (Just ".") [""]+ mapM_ (splash mime) mimes+ }++ putStrLn ""+ putStrLn $ "\226\157\130 Maid serving on port: " ++ show port+ putStrLn "" - run port $ loli $ do- public (Just ".") [""]- mapM_ (splash mime) mimes+ runWithConfig def {port} $ app+ + where+ log_access app = \env -> do+ time <- now+ let time_format = "%Y-%m-%d %H:%M:%S"+ time_stamp = format_time time_format time+ putStrLn $ time_stamp ++ " - " ++ url env+ app env mimes :: [(String, String)] mimes =