on master help sign in
Listing uses a Builder
commit6f207a0fa47923e404ed68f6d0539c01106866c1 authorMichael Snoyman <michael@snoyman.com> dateTue 22 May 2012, 06:06 (14 years ago) parent33fe04b
3 files changed+6−6
wai-app-static/Listing.hs+1−1 wai-app-static/Network/Wai/Application/Static.hs+3−3 wai-app-static/WaiAppStatic/Types.hs+2−2
wai-app-static/Listing.hs+1−1
@@ -27,7 +27,7 @@ defaultListing pieces (Folder _ contents) = do
2727 let isTop = null pieces || map Just pieces == [toPiece ""]
2828 let fps'' :: [Either Folder File]
2929 fps'' = (if isTop then id else (Left emptyParentFolder :)) contents -- FIXME emptyParentFolder feels like a bit of a hack
30− return $ HU.renderHtml
30+ return $ HU.renderHtmlBuilder
3131 $ H.html $ do
3232 H.head $ do
3333 let title = T.intercalate "/" $ map fromPiece pieces
wai-app-static/Network/Wai/Application/Static.hs+3−3
@@ -117,10 +117,10 @@ serveFolder ss@StaticSettings {..} pieces req folder@Folder {..} =
117117 case ssListing of
118118 Just listing -> do
119119 -- directory listings turned on, display it
120− lbs <- listing pieces folder
121− return $ WaiResponse $ W.responseLBS H.status200
120+ builder <- listing pieces folder
121+ return $ WaiResponse $ W.ResponseBuilder H.status200
122122 [ ("Content-Type", "text/html; charset=utf-8")
123− ] lbs
123+ ] builder
124124 Nothing -> return $ WaiResponse $ W.responseLBS H.status403
125125 [ ("Content-Type", "text/plain")
126126 ] "Directory listings disabled"
wai-app-static/WaiAppStatic/Types.hs+2−2
@@ -26,7 +26,7 @@ import Data.ByteString (ByteString)
2626import System.Posix.Types (EpochTime)
2727import qualified Data.Text as T
2828import qualified Data.Map as Map
29−import qualified Data.ByteString.Lazy as L
29+import Blaze.ByteString.Builder (Builder)
3030
3131-- | An individual component of a path, or of a filepath.
3232newtype Piece = Piece { fromPiece :: Text }
@@ -88,7 +88,7 @@ data LookupResult = LRFile File
8888 | LRFolder Folder
8989 | LRNotFound
9090
91−type Listing = Pieces -> Folder -> IO L.ByteString
91+type Listing = Pieces -> Folder -> IO Builder
9292
9393data StaticSettings = StaticSettings
9494 { -- | Lookup a single file or folder.