packages feed

wai-app-static 3.0.0.3 → 3.0.0.4

raw patch · 4 files changed

+31/−8 lines, 4 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- WaiAppStatic.CmdLine: [docroot] :: Args -> FilePath
- WaiAppStatic.CmdLine: [host] :: Args -> String
- WaiAppStatic.CmdLine: [index] :: Args -> [FilePath]
- WaiAppStatic.CmdLine: [mime] :: Args -> [(String, String)]
- WaiAppStatic.CmdLine: [noindex] :: Args -> Bool
- WaiAppStatic.CmdLine: [port] :: Args -> Int
- WaiAppStatic.CmdLine: [quiet] :: Args -> Bool
- WaiAppStatic.CmdLine: [verbose] :: Args -> Bool
- WaiAppStatic.Storage.Embedded: [eContent] :: EmbeddableEntry -> Either (Etag, ByteString) ExpQ
- WaiAppStatic.Storage.Embedded: [eLocation] :: EmbeddableEntry -> Text
- WaiAppStatic.Storage.Embedded: [eMimeType] :: EmbeddableEntry -> MimeType
- WaiAppStatic.Types: [fileGetHash] :: File -> IO (Maybe ByteString)
- WaiAppStatic.Types: [fileGetModified] :: File -> Maybe EpochTime
- WaiAppStatic.Types: [fileGetSize] :: File -> Int
- WaiAppStatic.Types: [fileName] :: File -> Piece
- WaiAppStatic.Types: [fileToResponse] :: File -> Status -> ResponseHeaders -> Response
- WaiAppStatic.Types: [folderContents] :: Folder -> [Either FolderName File]
- WaiAppStatic.Types: [ssGetMimeType] :: StaticSettings -> File -> IO MimeType
- WaiAppStatic.Types: [ssIndices] :: StaticSettings -> [Piece]
- WaiAppStatic.Types: [ssListing] :: StaticSettings -> Maybe Listing
- WaiAppStatic.Types: [ssLookupFile] :: StaticSettings -> Pieces -> IO LookupResult
- WaiAppStatic.Types: [ssMaxAge] :: StaticSettings -> MaxAge
- WaiAppStatic.Types: [ssMkRedirect] :: StaticSettings -> Pieces -> ByteString -> ByteString
- WaiAppStatic.Types: [ssRedirectToIndex] :: StaticSettings -> Bool
- WaiAppStatic.Types: [ssUseHash] :: StaticSettings -> Bool
- WaiAppStatic.Types: instance GHC.Classes.Eq WaiAppStatic.Types.Piece
- WaiAppStatic.Types: instance GHC.Classes.Ord WaiAppStatic.Types.Piece
- WaiAppStatic.Types: instance GHC.Show.Show WaiAppStatic.Types.Piece
+ WaiAppStatic.CmdLine: docroot :: Args -> FilePath
+ WaiAppStatic.CmdLine: host :: Args -> String
+ WaiAppStatic.CmdLine: index :: Args -> [FilePath]
+ WaiAppStatic.CmdLine: mime :: Args -> [(String, String)]
+ WaiAppStatic.CmdLine: noindex :: Args -> Bool
+ WaiAppStatic.CmdLine: port :: Args -> Int
+ WaiAppStatic.CmdLine: quiet :: Args -> Bool
+ WaiAppStatic.CmdLine: verbose :: Args -> Bool
+ WaiAppStatic.Storage.Embedded: eContent :: EmbeddableEntry -> Either (Etag, ByteString) ExpQ
+ WaiAppStatic.Storage.Embedded: eLocation :: EmbeddableEntry -> Text
+ WaiAppStatic.Storage.Embedded: eMimeType :: EmbeddableEntry -> MimeType
+ WaiAppStatic.Types: fileGetHash :: File -> IO (Maybe ByteString)
+ WaiAppStatic.Types: fileGetModified :: File -> Maybe EpochTime
+ WaiAppStatic.Types: fileGetSize :: File -> Int
+ WaiAppStatic.Types: fileName :: File -> Piece
+ WaiAppStatic.Types: fileToResponse :: File -> Status -> ResponseHeaders -> Response
+ WaiAppStatic.Types: folderContents :: Folder -> [Either FolderName File]
+ WaiAppStatic.Types: instance Eq Piece
+ WaiAppStatic.Types: instance Ord Piece
+ WaiAppStatic.Types: instance Show Piece
+ WaiAppStatic.Types: ssGetMimeType :: StaticSettings -> File -> IO MimeType
+ WaiAppStatic.Types: ssIndices :: StaticSettings -> [Piece]
+ WaiAppStatic.Types: ssListing :: StaticSettings -> Maybe Listing
+ WaiAppStatic.Types: ssLookupFile :: StaticSettings -> Pieces -> IO LookupResult
+ WaiAppStatic.Types: ssMaxAge :: StaticSettings -> MaxAge
+ WaiAppStatic.Types: ssMkRedirect :: StaticSettings -> Pieces -> ByteString -> ByteString
+ WaiAppStatic.Types: ssRedirectToIndex :: StaticSettings -> Bool
+ WaiAppStatic.Types: ssUseHash :: StaticSettings -> Bool

Files

ChangeLog.md view
@@ -1,1 +1,7 @@-__3.0.0.3__ Support for time 1.5+## 3.0.0.4++Add missing trailing slashes [#312](https://github.com/yesodweb/wai/issues/312)++## 3.0.0.3++Support for time 1.5
Network/Wai/Application/Static.hs view
@@ -2,6 +2,7 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TemplateHaskell, CPP #-} {-# LANGUAGE RecordWildCards #-}+{-# LANGUAGE PatternGuards #-} -- | Static file serving for WAI. module Network.Wai.Application.Static     ( -- * WAI application@@ -74,14 +75,19 @@ serveFolder ss@StaticSettings {..} pieces req folder@Folder {..} =     -- first check if there is an index file in this folder     case getFirst $ mconcat $ map (findIndex $ rights folderContents) ssIndices of-        Just index -> do-            let pieces' = setLast pieces index-             in if ssRedirectToIndex-                    then return $ Redirect pieces' Nothing+        Just index ->+            let pieces' = setLast pieces index in+            case () of+              () | ssRedirectToIndex -> return $ Redirect pieces' Nothing+                 | noTrailingSlash pieces, Just trailing <- toPiece ""  ->+                    return $ Redirect (pieces ++ [trailing]) Nothing+                 | otherwise ->                     -- start the checking process over, with a new set-                    else checkPieces ss pieces' req+                    checkPieces ss pieces' req         Nothing ->             case ssListing of+                Just _ | noTrailingSlash pieces, Just trailing <- toPiece "" ->+                    return $ Redirect (pieces ++ [trailing]) Nothing                 Just listing -> do                     -- directory listings turned on, display it                     builder <- listing pieces folder@@ -97,6 +103,11 @@     setLast [t] x         | fromPiece t == "" = [x]     setLast (a:b) x = a : setLast b x++    noTrailingSlash :: Pieces -> Bool+    noTrailingSlash [] = False+    noTrailingSlash [x] = fromPiece x /= ""+    noTrailingSlash (_:xs) = noTrailingSlash xs      findIndex :: [File] -> Piece -> First Piece     findIndex files index
+ README.md view
@@ -0,0 +1,5 @@+## wai-app-static++WAI application for static serving++Also provides some helper functions and datatypes for use outside of WAI.
wai-app-static.cabal view
@@ -1,11 +1,11 @@ name:            wai-app-static-version:         3.0.0.3+version:         3.0.0.4 license:         MIT license-file:    LICENSE author:          Michael Snoyman <michael@snoyman.com> maintainer:      Michael Snoyman <michael@snoyman.com>, Greg Weber <greg@gregweber.info> synopsis:        WAI application for static serving-description:     Also provides some helper functions and datatypes for use outside of WAI.+description:     Hackage documentation generation is not reliable. For up to date documentation, please see: <http://www.stackage.org/package/wai-app-static>. category:        Web, Yesod stability:       Stable cabal-version:   >= 1.8@@ -17,6 +17,7 @@   test/*.hs   test/a/b   tests.hs+  README.md   ChangeLog.md  Flag print