salvia-1.0.0: Modular web application framework.

Network.Salvia.Handler.File

Synopsis

Documentation

hFile :: (MonadIO m, HttpM' m, SendM m) => m ()Source

Like hFileResource but uses the path of the current request URI.

hFileResource :: (MonadIO m, HttpM' m, SendM m) => FilePath -> m ()Source

Serve a file from the filesystem indicated by the specified filepath. When there is some kind of IOError the hSafeIO function will be used to produce a corresponding error response. The contentType will be the mime-type based on the filename extension using the mimetype function. The contentLength will be set the file's size.

hFileFilter :: (MonadIO m, HttpM' m, SendM m) => (String -> String) -> m ()Source

Like hFileResourceFilter but uses the path of the current request URI.

hFileResourceFilter :: (MonadIO m, HttpM Response m, SendM m) => (String -> String) -> FilePath -> m ()Source

Like the hFileResource handler, but with a custom filter over the content. This function will assume the content is an UTF-8 encoded text file. Because of the possibly unpredictable behavior of the filter, no contentLength header will be set using this handler.

hResource :: HttpM Request m => (FilePath -> m a) -> m aSource

Turn a handler that is parametrized by a file resources into a regular handler that utilizes the path part of the request URI as the resource identifier.

hUri :: HttpM Request m => (Uri -> m a) -> m aSource

Turn a handler that is parametrized by a URI into a regular handler that utilizes the request URI as the resource identifier.