on master help sign in
autohead, debug and gzip middleware
commit01c9c11a2f3348774c4699cf8b0a829eecdb7a24 authorMichael Snoyman <michael@snoyman.com> dateTue 15 Mar 2011, 09:22 (16 years ago) parent97ded72
2 files changed+11−3
warp-static.cabal+2−1 warp.hs+9−2
warp-static.cabal+2−1
@@ -1,5 +1,5 @@
11Name: warp-static
2−Version: 0.0.1
2+Version: 0.0.2
33Synopsis: Static file server based on Warp and wai-app-static
44Homepage: http://github.com/snoyberg/warp-static
55License: BSD3
@@ -16,5 +16,6 @@ Executable warp
1616 Build-depends: base >= 4 && < 5
1717 , warp >= 0.3 && < 0.4
1818 , wai-app-static >= 0.0 && < 0.1
19+ , wai-extra >= 0.3.3 && < 0.4
1920 , cmdargs >= 0.6.7 && < 0.7
2021 , directory >= 1.0 && < 1.2
warp.hs+9−2
@@ -8,6 +8,9 @@ import System.Console.CmdArgs
88import Text.Printf (printf)
99import System.Directory (canonicalizePath)
1010import Control.Monad (unless)
11+import Network.Wai.Middleware.Autohead
12+import Network.Wai.Middleware.Debug
13+import Network.Wai.Middleware.Gzip
1114
1215data Args = Args
1316 { docroot :: FilePath
@@ -15,10 +18,11 @@ data Args = Args
1518 , port :: Int
1619 , noindex :: Bool
1720 , quiet :: Bool
21+ , verbose :: Bool
1822 }
1923 deriving (Show, Data, Typeable)
2024
21−defaultArgs = Args "." ["index.html", "index.htm"] 3000 False False
25+defaultArgs = Args "." ["index.html", "index.htm"] 3000 False False False
2226
2327main :: IO ()
2428main = do
@@ -26,7 +30,10 @@ main = do
2630 docroot' <- canonicalizePath docroot
2731 args <- getArgs
2832 unless quiet $ printf "Serving directory %s on port %d with %s index files.\n" docroot' port (if noindex then "no" else show index)
29− run port $ staticApp StaticSettings
33+ let middle = gzip False
34+ . (if verbose then debug else id)
35+ . autohead
36+ run port $ middle $ staticApp StaticSettings
3037 { ssFolder = docroot
3138 , ssIndices = if noindex then [] else index
3239 , ssListing = Just defaultListing