wai-app-static-3.1.6.1: WAI application for static serving

Safe Haskell | None
Language | Haskell98

Network.Wai.Application.Static

Contents

- WAI application
  - Default Settings
  - Settings

Description

Static file serving for WAI.

Synopsis

- staticApp :: StaticSettings -> Application
- defaultWebAppSettings :: FilePath -> StaticSettings
- webAppSettingsWithLookup :: FilePath -> ETagLookup -> StaticSettings
- defaultFileServerSettings :: FilePath -> StaticSettings
- embeddedSettings :: [(FilePath, ByteString)] -> StaticSettings
- data StaticSettings
- ssLookupFile :: StaticSettings -> Pieces -> IO LookupResult
- ssMkRedirect :: StaticSettings -> Pieces -> ByteString -> ByteString
- ssGetMimeType :: StaticSettings -> File -> IO MimeType
- ssListing :: StaticSettings -> Maybe Listing
- ssIndices :: StaticSettings -> [Piece]
- ssMaxAge :: StaticSettings -> MaxAge
- ssRedirectToIndex :: StaticSettings -> Bool
- ssAddTrailingSlash :: StaticSettings -> Bool
- ss404Handler :: StaticSettings -> Maybe Application

# WAI application

staticApp :: StaticSettings -> Application #

Turn a `StaticSettings` into a WAI application.

## Default Settings

defaultWebAppSettings #

Arguments

:: FilePath | root folder to serve from
-> StaticSettings |

Settings optimized for a web application. Files will have aggressive caching applied and hashes calculated, and indices and listings are disabled.

webAppSettingsWithLookup #

Arguments

:: FilePath | root folder to serve from
-> ETagLookup |
-> StaticSettings |

Same as `defaultWebAppSettings`, but additionally uses a specialized `ETagLookup` in place of the standard one. This can allow you to cache your hash values, or even precompute them.

defaultFileServerSettings #

Arguments

:: FilePath | root folder to serve from
-> StaticSettings |

Settings optimized for a file server. More conservative caching will be applied, and indices and listings are enabled.

embeddedSettings :: [(FilePath, ByteString)] -> StaticSettings #

Serve the list of path/content pairs directly from memory.

## Settings

data StaticSettings #

All of the settings available to users for tweaking wai-app-static.

Note that you should use the settings type approach for modifying values. See http://www.yesodweb.com/book/settings-types for more information.

ssLookupFile :: StaticSettings -> Pieces -> IO LookupResult #

Lookup a single file or folder. This is how you can control storage backend (filesystem, embedded, etc) and where to lookup.

ssMkRedirect :: StaticSettings -> Pieces -> ByteString -> ByteString #

Given a requested path and a new destination, construct a string that will go there. Default implementation will use relative paths.

ssGetMimeType :: StaticSettings -> File -> IO MimeType #

Determine the mime type of the given file. Note that this function lives in `IO` in case you want to perform more complicated mimetype analysis, such as via the `file` utility.

ssListing :: StaticSettings -> Maybe Listing #

How to perform a directory listing. Optional. Will be used when the user requested a folder.

ssIndices :: StaticSettings -> [Piece] #

Ordered list of filenames to be used for indices. If the user requests a folder, and a file with the given name is found in that folder, that file is served. This supercedes any directory listing.

ssMaxAge :: StaticSettings -> MaxAge #

Value to provide for max age in the cache-control.

ssRedirectToIndex :: StaticSettings -> Bool #

If `True`, send a redirect to the user when a folder is requested and an index page should be displayed. When `False`, display the content immediately.

ssAddTrailingSlash :: StaticSettings -> Bool #

Force a trailing slash at the end of directories

ss404Handler :: StaticSettings -> Maybe Application #

Optional `Application` to be used in case of 404 errors

Since 3.1.3