wai-app-static 2.0.1.1 → 3.0.0
raw patch · 3 files changed
+23/−28 lines, 3 filesdep −wai-testdep ~basedep ~cryptohash-conduitdep ~http-typesPVP ok
version bump matches the API change (PVP)
Dependencies removed: wai-test
Dependency ranges changed: base, cryptohash-conduit, http-types, optparse-applicative, wai, wai-app-static, wai-extra, warp
API changes (from Hackage documentation)
Files
- Network/Wai/Application/Static.hs +13/−13
- WaiAppStatic/CmdLine.hs +1/−7
- wai-app-static.cabal +9/−8
Network/Wai/Application/Static.hs view
@@ -193,35 +193,35 @@ staticApp set req = staticAppPieces set (W.pathInfo req) req staticAppPieces :: StaticSettings -> [Text] -> W.Application-staticAppPieces _ _ req- | W.requestMethod req /= "GET" = return $ W.responseLBS+staticAppPieces _ _ req sendResponse+ | W.requestMethod req /= "GET" = sendResponse $ W.responseLBS H.status405 [("Content-Type", "text/plain")] "Only GET is supported"-staticAppPieces _ [".hidden", "folder.png"] _ = return $ W.responseLBS H.status200 [("Content-Type", "image/png")] $ L.fromChunks [$(embedFile "images/folder.png")]-staticAppPieces _ [".hidden", "haskell.png"] _ = return $ W.responseLBS H.status200 [("Content-Type", "image/png")] $ L.fromChunks [$(embedFile "images/haskell.png")]-staticAppPieces ss rawPieces req = liftIO $ do+staticAppPieces _ [".hidden", "folder.png"] _ sendResponse = sendResponse $ W.responseLBS H.status200 [("Content-Type", "image/png")] $ L.fromChunks [$(embedFile "images/folder.png")]+staticAppPieces _ [".hidden", "haskell.png"] _ sendResponse = sendResponse $ W.responseLBS H.status200 [("Content-Type", "image/png")] $ L.fromChunks [$(embedFile "images/haskell.png")]+staticAppPieces ss rawPieces req sendResponse = liftIO $ do case toPieces rawPieces of Just pieces -> checkPieces ss pieces req >>= response- Nothing -> return $ W.responseLBS H.status403+ Nothing -> sendResponse $ W.responseLBS H.status403 [ ("Content-Type", "text/plain") ] "Forbidden" where- response :: StaticResponse -> IO W.Response+ response :: StaticResponse -> IO W.ResponseReceived response (FileResponse file ch) = do mimetype <- ssGetMimeType ss file let filesize = fileGetSize file let headers = ("Content-Type", mimetype) : ("Content-Length", S8.pack $ show filesize) : ch- return $ fileToResponse file H.status200 headers+ sendResponse $ fileToResponse file H.status200 headers response NotModified =- return $ W.responseLBS H.status304 [] ""+ sendResponse $ W.responseLBS H.status304 [] "" response (SendContent mt lbs) = do -- TODO: set caching headers- return $ W.responseLBS H.status200+ sendResponse $ W.responseLBS H.status200 [ ("Content-Type", mt) -- TODO: set Content-Length ] lbs@@ -232,13 +232,13 @@ Just hash -> replace "etag" (Just hash) (W.queryString req) Nothing -> remove "etag" (W.queryString req) - return $ W.responseLBS H.status301+ sendResponse $ W.responseLBS H.status301 [ ("Content-Type", "text/plain") , ("Location", S8.append loc $ H.renderQuery True qString) ] "Redirect" - response NotFound = return $ W.responseLBS H.status404+ response NotFound = sendResponse $ W.responseLBS H.status404 [ ("Content-Type", "text/plain") ] "File not found" - response (WaiResponse r) = return r+ response (WaiResponse r) = sendResponse r
WaiAppStatic/CmdLine.hs view
@@ -38,12 +38,6 @@ , host :: String } -#if MIN_VERSION_optparse_applicative(0, 10, 0)-option' = option auto-#else-option' = option-#endif- args :: Parser Args args = Args <$> strOption@@ -58,7 +52,7 @@ <> metavar "INDEX" <> help "index files to serve when a directory is required" )))- <*> option'+ <*> option ( long "port" <> short 'p' <> metavar "PORT"
wai-app-static.cabal view
@@ -1,5 +1,5 @@ name: wai-app-static-version: 2.0.1.1+version: 3.0.0 license: MIT license-file: LICENSE author: Michael Snoyman <michael@snoyman.com>@@ -24,7 +24,7 @@ library build-depends: base >= 4 && < 5- , wai >= 2.0 && < 2.2+ , wai >= 3.0 && < 3.1 , bytestring >= 0.9.1.4 , http-types >= 0.7 , transformers >= 0.2.2@@ -39,7 +39,6 @@ , base64-bytestring >= 0.1 , byteable , cryptohash >= 0.11- , cryptohash-conduit >= 0.1.0 , system-filepath >= 0.4 , system-fileio >= 0.3 , http-date@@ -50,9 +49,11 @@ , template-haskell >= 2.7 , zlib >= 0.5 , filepath- , wai-extra >= 2.0 && < 2.2+ , wai-extra >= 3.0 && < 3.1 , optparse-applicative >= 0.7- , warp >= 2.0 && < 2.2+ , warp >= 3.0 && < 3.1+ -- Used exclusively for hashFile function+ , cryptohash-conduit exposed-modules: Network.Wai.Application.Static WaiAppStatic.Storage.Filesystem@@ -73,7 +74,7 @@ Main-is: warp-static.hs hs-source-dirs: app Build-depends: base >= 4 && < 5- , wai-app-static >= 2.0 && < 2.1+ , wai-app-static , directory >= 1.0 , containers >= 0.2 , bytestring >= 0.9.1.4@@ -91,8 +92,8 @@ , time , old-locale , http-date- , wai-app-static >= 1.3- , wai-test+ , wai-app-static+ , wai-extra , wai , http-types , network