warp-static 0.2.2 → 1.0.0
raw patch · 2 files changed
+17/−11 lines, 2 filesdep ~wai-app-staticdep ~wai-extradep ~warp
Dependency ranges changed: wai-app-static, wai-extra, warp
Files
- warp-static.cabal +4/−4
- warp.hs +13/−7
warp-static.cabal view
@@ -1,5 +1,5 @@ Name: warp-static-Version: 0.2.2+Version: 1.0.0 Synopsis: Static file server based on Warp and wai-app-static Homepage: http://github.com/yesodweb/wai License: BSD3@@ -15,9 +15,9 @@ Executable warp Main-is: warp.hs Build-depends: base >= 4 && < 5- , warp >= 0.4 && < 0.5- , wai-app-static >= 0.3 && < 0.4- , wai-extra >= 0.4 && < 0.5+ , warp >= 1.0 && < 1.1+ , wai-app-static >= 1.0 && < 1.1+ , wai-extra >= 1.0 && < 1.1 , cmdargs >= 0.6.7 , directory >= 1.0 , containers >= 0.2 && < 0.5
warp.hs view
@@ -5,13 +5,15 @@ , defaultFileServerSettings, fileSystemLookup , fileName, toFilePath )-import Network.Wai.Handler.Warp (run)-import System.Console.CmdArgs+import Network.Wai.Handler.Warp+ ( runSettings, defaultSettings, settingsHost, settingsPort+ )+import System.Console.CmdArgs hiding (def) import Text.Printf (printf) import System.Directory (canonicalizePath) import Control.Monad (unless) import Network.Wai.Middleware.Autohead-import Network.Wai.Middleware.Debug+import Network.Wai.Middleware.RequestLogger (logStdout) import Network.Wai.Middleware.Gzip import qualified Data.Map as Map import qualified Data.ByteString.Char8 as S8@@ -26,11 +28,12 @@ , quiet :: Bool , verbose :: Bool , mime :: [(String, String)]+ , host :: String } deriving (Show, Data, Typeable) defaultArgs :: Args-defaultArgs = Args "." ["index.html", "index.htm"] 3000 False False False []+defaultArgs = Args "." ["index.html", "index.htm"] 3000 False False False [] "*" main :: IO () main = do@@ -39,10 +42,13 @@ let mimeMap = Map.fromList mime' `Map.union` defaultMimeTypes docroot' <- canonicalizePath docroot unless quiet $ printf "Serving directory %s on port %d with %s index files.\n" docroot' port (if noindex then "no" else show index)- let middle = gzip False- . (if verbose then debug else id)+ let middle = gzip def+ . (if verbose then logStdout else id) . autohead- run port $ middle $ staticApp defaultFileServerSettings+ runSettings defaultSettings+ { settingsPort = port+ , settingsHost = host+ } $ middle $ staticApp defaultFileServerSettings { ssFolder = fileSystemLookup $ toFilePath docroot , ssIndices = if noindex then [] else map pack index , ssListing = Just defaultListing