warp-static 0.1.1 → 0.2.0
raw patch · 2 files changed
+12/−8 lines, 2 filesdep +textdep ~wai-app-static
Dependencies added: text
Dependency ranges changed: wai-app-static
Files
- warp-static.cabal +3/−2
- warp.hs +9/−6
warp-static.cabal view
@@ -1,5 +1,5 @@ Name: warp-static-Version: 0.1.1+Version: 0.2.0 Synopsis: Static file server based on Warp and wai-app-static Homepage: http://github.com/snoyberg/warp-static License: BSD3@@ -15,9 +15,10 @@ Main-is: warp.hs Build-depends: base >= 4 && < 5 , warp >= 0.4 && < 0.5- , wai-app-static >= 0.1 && < 0.2+ , wai-app-static >= 0.3 && < 0.4 , wai-extra >= 0.4 && < 0.5 , cmdargs >= 0.6.7 && < 0.8 , directory >= 1.0 && < 1.2 , containers >= 0.2 && < 0.5 , bytestring >= 0.9 && < 0.10+ , text < 1.0
warp.hs view
@@ -2,6 +2,8 @@ import Network.Wai.Application.Static ( StaticSettings (..), staticApp, defaultMimeType, defaultListing , defaultMimeTypes, mimeTypeByExt+ , defaultFileServerSettings, fileSystemLookup+ , fileName, toFilePath ) import Network.Wai.Handler.Warp (run) import System.Environment (getArgs)@@ -14,7 +16,8 @@ import Network.Wai.Middleware.Gzip import qualified Data.Map as Map import qualified Data.ByteString.Char8 as S8-import Control.Arrow (second)+import Control.Arrow ((***))+import Data.Text (pack, unpack) data Args = Args { docroot :: FilePath@@ -32,7 +35,7 @@ main :: IO () main = do Args {..} <- cmdArgs defaultArgs- let mime' = map (second S8.pack) mime+ let mime' = map (toFilePath *** S8.pack) mime let mimeMap = Map.fromList mime' `Map.union` defaultMimeTypes docroot' <- canonicalizePath docroot args <- getArgs@@ -40,9 +43,9 @@ let middle = gzip False . (if verbose then debug else id) . autohead- run port $ middle $ staticApp StaticSettings- { ssFolder = docroot- , ssIndices = if noindex then [] else index+ run port $ middle $ staticApp defaultFileServerSettings+ { ssFolder = fileSystemLookup $ toFilePath docroot+ , ssIndices = if noindex then [] else map pack index , ssListing = Just defaultListing- , ssGetMimeType = return . mimeTypeByExt mimeMap defaultMimeType+ , ssGetMimeType = return . mimeTypeByExt mimeMap defaultMimeType . fileName }