packages feed

warp-static 0.0.2 → 0.0.3

raw patch · 2 files changed

+13/−4 lines, 2 filesdep +bytestringdep +containers

Dependencies added: bytestring, containers

Files

warp-static.cabal view
@@ -1,5 +1,5 @@ Name:                warp-static-Version:             0.0.2+Version:             0.0.3 Synopsis:            Static file server based on Warp and wai-app-static Homepage:            http://github.com/snoyberg/warp-static License:             BSD3@@ -19,3 +19,5 @@                , wai-extra       >= 0.3.3              && < 0.4                , cmdargs         >= 0.6.7              && < 0.7                , directory       >= 1.0                && < 1.2+               , containers      >= 0.2                && < 0.5+               , bytestring      >= 0.9                && < 0.10
warp.hs view
@@ -1,6 +1,7 @@ {-# LANGUAGE DeriveDataTypeable, RecordWildCards #-} import Network.Wai.Application.Static-    ( StaticSettings (..), staticApp, defaultMimeTypeByExt, defaultListing+    ( StaticSettings (..), staticApp, defaultMimeType, defaultListing+    , defaultMimeTypes, mimeTypeByExt     ) import Network.Wai.Handler.Warp (run) import System.Environment (getArgs)@@ -11,6 +12,9 @@ import Network.Wai.Middleware.Autohead import Network.Wai.Middleware.Debug import Network.Wai.Middleware.Gzip+import qualified Data.Map as Map+import qualified Data.ByteString.Char8 as S8+import Control.Arrow (second)  data Args = Args     { docroot :: FilePath@@ -19,14 +23,17 @@     , noindex :: Bool     , quiet :: Bool     , verbose :: Bool+    , mime :: [(String, String)]     }     deriving (Show, Data, Typeable) -defaultArgs = Args "." ["index.html", "index.htm"] 3000 False False False+defaultArgs = Args "." ["index.html", "index.htm"] 3000 False False False []  main :: IO () main = do     Args {..} <- cmdArgs defaultArgs+    let mime' = map (second S8.pack) mime+    let mimeMap = Map.fromList mime' `Map.union` defaultMimeTypes     docroot' <- canonicalizePath docroot     args <- getArgs     unless quiet $ printf "Serving directory %s on port %d with %s index files.\n" docroot' port (if noindex then "no" else show index)@@ -37,5 +44,5 @@         { ssFolder = docroot         , ssIndices = if noindex then [] else index         , ssListing = Just defaultListing-        , ssGetMimeType = return . defaultMimeTypeByExt+        , ssGetMimeType = return . mimeTypeByExt mimeMap defaultMimeType         }