yesod-static uses fileSystemLookupHash

This commit is contained in:
Michael Snoyman 2011-08-22 22:01:50 +03:00
parent 4ddbf85a90
commit 3bee4e7b13

View File

@ -71,12 +71,14 @@ import Network.HTTP.Types (status301)
import Network.Wai.Application.Static import Network.Wai.Application.Static
( StaticSettings (..) ( StaticSettings (..)
, defaultWebAppSettings , defaultWebAppSettings
, fileSystemLookup , fileSystemLookupHash
, staticApp , staticApp
, embeddedLookup , embeddedLookup
, toEmbedded , toEmbedded
-- , pathFromPieces -- , pathFromPieces
, toFilePath , toFilePath
, fromFilePath
, FilePath
) )
newtype Static = Static StaticSettings newtype Static = Static StaticSettings
@ -84,13 +86,16 @@ newtype Static = Static StaticSettings
-- | Default value of 'Static' for a given file folder. -- | Default value of 'Static' for a given file folder.
-- --
-- Does not have index files or directory listings. -- Does not have index files or directory listings.
static :: Prelude.FilePath -> Static static :: Prelude.FilePath -> IO Static
static fp = static fp = do
--hashes <- mkHashMap fp hashes <- mkHashMap fp
Static $ defaultWebAppSettings { return $ Static defaultWebAppSettings{
ssFolder = fileSystemLookup $ toFilePath fp ssFolder = fileSystemLookupHash (getHash hashes) (toFilePath fp)
} }
getHash :: M.Map Prelude.FilePath S.ByteString -> FilePath -> Maybe (IO S.ByteString)
getHash m fp = fmap return $ M.lookup (fromFilePath fp) m
-- | Produces a 'Static' based on embedding file contents in the executable at -- | Produces a 'Static' based on embedding file contents in the executable at
-- compile time. -- compile time.
embed :: Prelude.FilePath -> Q Exp embed :: Prelude.FilePath -> Q Exp