yesod-static uses fileSystemLookupHash
This commit is contained in:
parent
4ddbf85a90
commit
3bee4e7b13
@ -71,12 +71,14 @@ import Network.HTTP.Types (status301)
|
||||
import Network.Wai.Application.Static
|
||||
( StaticSettings (..)
|
||||
, defaultWebAppSettings
|
||||
, fileSystemLookup
|
||||
, fileSystemLookupHash
|
||||
, staticApp
|
||||
, embeddedLookup
|
||||
, toEmbedded
|
||||
-- , pathFromPieces
|
||||
, toFilePath
|
||||
, fromFilePath
|
||||
, FilePath
|
||||
)
|
||||
|
||||
newtype Static = Static StaticSettings
|
||||
@ -84,13 +86,16 @@ newtype Static = Static StaticSettings
|
||||
-- | Default value of 'Static' for a given file folder.
|
||||
--
|
||||
-- Does not have index files or directory listings.
|
||||
static :: Prelude.FilePath -> Static
|
||||
static fp =
|
||||
--hashes <- mkHashMap fp
|
||||
Static $ defaultWebAppSettings {
|
||||
ssFolder = fileSystemLookup $ toFilePath fp
|
||||
static :: Prelude.FilePath -> IO Static
|
||||
static fp = do
|
||||
hashes <- mkHashMap fp
|
||||
return $ Static defaultWebAppSettings{
|
||||
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
|
||||
-- compile time.
|
||||
embed :: Prelude.FilePath -> Q Exp
|
||||
|
||||
Loading…
Reference in New Issue
Block a user