@@ -2,6 +2,8 @@
22import Network.Wai.Application.Static
33 ( StaticSettings (..), staticApp, defaultMimeType, defaultListing
44 , defaultMimeTypes, mimeTypeByExt
5+ , defaultFileServerSettings, fileSystemLookup
6+ , fileName, toFilePath
57 )
68import Network.Wai.Handler.Warp (run)
79import System.Environment (getArgs)
@@ -14,7 +16,8 @@ import Network.Wai.Middleware.Debug
1416import Network.Wai.Middleware.Gzip
1517import qualified Data.Map as Map
1618import qualified Data.ByteString.Char8 as S8
17−import Control.Arrow (second)
19+import Control.Arrow ((***))
20+import Data.Text (pack, unpack)
1821
1922data Args = Args
2023 { docroot :: FilePath
@@ -32,7 +35,7 @@ defaultArgs = Args "." ["index.html", "index.htm"] 3000 False False False []
3235main :: IO ()
3336main = do
3437 Args {..} <- cmdArgs defaultArgs
35− let mime' = map (second S8.pack) mime
38+ let mime' = map (toFilePath *** S8.pack) mime
3639 let mimeMap = Map.fromList mime' `Map.union` defaultMimeTypes
3740 docroot' <- canonicalizePath docroot
3841 args <- getArgs
@@ -40,9 +43,9 @@ main = do
4043 let middle = gzip False
4144 . (if verbose then debug else id)
4245 . autohead
43− run port $ middle $ staticApp StaticSettings
44− { ssFolder = docroot
45− , ssIndices = if noindex then [] else index
46+ run port $ middle $ staticApp defaultFileServerSettings
47+ { ssFolder = fileSystemLookup $ toFilePath docroot
48+ , ssIndices = if noindex then [] else map pack index
4649 , ssListing = Just defaultListing
47− , ssGetMimeType = return . mimeTypeByExt mimeMap defaultMimeType
50+ , ssGetMimeType = return . mimeTypeByExt mimeMap defaultMimeType . fileName
4851 }