happstack-server-0.3.3: Web related tools and services.Source codeContentsIndex
Happstack.Server.HTTP.FileServe
Synopsis
type MimeMap = Map String String
blockDotFiles :: (Request -> IO Response) -> Request -> IO Response
doIndex :: (ServerMonad m, FilterMonad Response m, MonadIO m) => [String] -> MimeMap -> String -> m Response
doIndexStrict :: (ServerMonad m, FilterMonad Response m, MonadIO m) => [String] -> MimeMap -> String -> m Response
errorwrapper :: (MonadIO m, MonadPlus m, FilterMonad Response m) => String -> String -> m Response
fileServe :: (WebMonad Response m, ServerMonad m, FilterMonad Response m, MonadIO m) => [FilePath] -> FilePath -> m Response
fileServeStrict :: (ServerMonad m, FilterMonad Response m, MonadIO m) => [FilePath] -> FilePath -> m Response
isDot :: String -> Bool
mimeTypes :: MimeMap
Documentation
type MimeMap = Map String StringSource
blockDotFiles :: (Request -> IO Response) -> Request -> IO ResponseSource
Prevents files of the form '.foo' or 'bar/.foo' from being served
doIndex :: (ServerMonad m, FilterMonad Response m, MonadIO m) => [String] -> MimeMap -> String -> m ResponseSource
doIndexStrict :: (ServerMonad m, FilterMonad Response m, MonadIO m) => [String] -> MimeMap -> String -> m ResponseSource
A variant of doIndex that relies on getFileStrict
errorwrapper :: (MonadIO m, MonadPlus m, FilterMonad Response m) => String -> String -> m ResponseSource
fileServeSource
:: (WebMonad Response m, ServerMonad m, FilterMonad Response m, MonadIO m)
=> [FilePath]index files if the path is a directory
-> FilePathfile/directory to serve
-> m Response

Serve a file (lazy version). For efficiency reasons when serving large files, will escape the computation early if a file is successfully served, to prevent filters from being applied; if a filter were applied, we would need to compute the content-length (thereby forcing the spine of the ByteString into memory) rather than reading it from the filesystem.

Note that using lazy fileServe can result in some filehandles staying open until the garbage collector gets around to closing them.

fileServeStrictSource
:: (ServerMonad m, FilterMonad Response m, MonadIO m)
=> [FilePath]index files if the path is a directory
-> FilePathfile/directory to serve
-> m Response
Serve a file (strict version). Reads the entire file strictly into memory, and ensures that the handle is properly closed. Unlike lazy fileServe, this function doesn't shortcut the computation early, and it allows for filtering (ex: gzip compression) to be applied
isDot :: String -> BoolSource
Returns True if the given String either starts with a . or is of the form foo/.bar, e.g. the typical *nix convention for hidden files.
mimeTypes :: MimeMapSource
Ready collection of common mime types.
Produced by Haddock version 2.4.2