packages feed

warp-static 1.2.0.2 → 1.3.0

raw patch · 2 files changed

+15/−20 lines, 2 filesdep +mime-typesdep ~wai-app-staticdep ~wai-extradep ~warp

Dependencies added: mime-types

Dependency ranges changed: wai-app-static, wai-extra, warp

Files

warp-static.cabal view
@@ -1,5 +1,5 @@ Name:                warp-static-Version:             1.2.0.2+Version:             1.3.0 Synopsis:            Static file server based on Warp and wai-app-static Homepage:            http://github.com/yesodweb/wai License:             MIT@@ -15,14 +15,15 @@ Executable warp   Main-is:       warp.hs   Build-depends: base            >= 4                  && < 5-               , warp            >= 1.2                && < 1.3-               , wai-app-static  >= 1.2                && < 1.3-               , wai-extra       >= 1.2                && < 1.3+               , warp            >= 1.3                && < 1.4+               , wai-app-static  >= 1.3                && < 1.4+               , wai-extra       >= 1.3                && < 1.4                , cmdargs         >= 0.6.7                , directory       >= 1.0                , containers      >= 0.2                , bytestring      >= 0.9.1.4-               , text                     >= 0.7           && < 0.12+               , text            >= 0.7                && < 0.12+               , mime-types      >= 0.1                && < 0.2  source-repository head   type:     git
warp.hs view
@@ -1,11 +1,5 @@ {-# LANGUAGE DeriveDataTypeable, RecordWildCards #-}-import Network.Wai.Application.Static-    ( StaticSettings (..), staticApp, defaultMimeType, defaultListing-    , defaultMimeTypes, mimeTypeByExt-    , defaultFileServerSettings, fileSystemLookup-    , fileName, toFilePath-    , ssRedirectToIndex-    )+import Network.Wai.Application.Static (staticApp, defaultFileServerSettings) import Network.Wai.Handler.Warp     ( runSettings, defaultSettings, settingsHost, settingsPort     )@@ -21,6 +15,9 @@ import Control.Arrow ((***)) import Data.Text (pack) import Data.String (fromString)+import Network.Mime (defaultMimeMap, mimeByExt, defaultMimeType)+import WaiAppStatic.Types (ssIndices, toPiece, ssGetMimeType, fileName, fromPiece)+import Data.Maybe (mapMaybe)  data Args = Args     { docroot :: FilePath@@ -40,8 +37,8 @@ main :: IO () main = do     Args {..} <- cmdArgs defaultArgs-    let mime' = map (toFilePath *** S8.pack) mime-    let mimeMap = Map.fromList mime' `Map.union` defaultMimeTypes+    let mime' = map (pack *** S8.pack) mime+    let mimeMap = Map.fromList mime' `Map.union` defaultMimeMap     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 def@@ -50,10 +47,7 @@     runSettings defaultSettings         { settingsPort = port         , settingsHost = fromString host-        } $ middle $ staticApp defaultFileServerSettings-        { ssFolder = fileSystemLookup $ toFilePath docroot-        , ssIndices = if noindex then [] else map pack index-        , ssRedirectToIndex = False-        , ssListing = Just defaultListing-        , ssGetMimeType = return . mimeTypeByExt mimeMap defaultMimeType . fileName+        } $ middle $ staticApp (defaultFileServerSettings $ fromString docroot)+        { ssIndices = if noindex then [] else mapMaybe (toPiece . pack) index+        , ssGetMimeType = return . mimeByExt mimeMap defaultMimeType . fromPiece . fileName         }