wai-app-file-cgi-0.3.0: File/CGI App of WAI

Network.Wai.Application.Classic

Contents

Description

WAI (Web Application Interface) Application for static files and CGI.

Synopsis

Types

data AppSpec Source

Constructors

AppSpec 

Fields

softwareName :: ByteString

Name specified to Server: in HTTP response.

indexFile :: ByteString

A file name of an index file.

isHTML :: ByteString -> Bool

Whether this is an HTML or not.

logger :: Logger

A function for logging. The third argument is a body size.

getFileInfo :: ByteString -> IO (Maybe FileInfo)

A function to obtain information about a file.

Files

data FileRoute Source

Constructors

FileRoute 

Fields

fileSrc :: ByteString

Path prefix to be matched to pathInfo.

fileDst :: ByteString

Path prefix to an actual file system.

fileApp :: AppSpec -> FileRoute -> ApplicationSource

Handle GET and HEAD for a static file.

If pathInfo ends with '/', indexFile is automatically added. In this case, Acceptable-Language: is also handled. Suppose indexFile is index.html and if the value is ja,en, then "index.html.ja", "index.html.en", and "index.html" are tried to be opened in order.

If pathInfo does not end with '/' and a corresponding index file exist, redirection is specified in HTTP response.

Directory contents are NOT automatically listed. To list directory contents, an index file must be created beforehand.

The following HTTP headers are handled: Acceptable-Language:, If-Modified-Since:, Range:, If-Range:, If-Unmodified-Since:.

CGI

data CgiRoute Source

Constructors

CgiRoute 

Fields

cgiSrc :: ByteString

Path prefix to be matched to pathInfo.

cgiDst :: ByteString

Path prefix to an actual file system.

cgiApp :: AppSpec -> CgiRoute -> ApplicationSource

Handle GET and POST for CGI.

The program to link this library must ignore SIGCHLD as follows:

   installHandler sigCHLD Ignore Nothing

Utilities for logging

type NumericAddress = StringSource

A type for IP address in numeric string representation.

showSockAddr :: SockAddr -> NumericAddressSource

Convert SockAddr to NumericAddress. If the address is an IPv4-embedded IPv6 address, the IPv4 is extracted.

type FieldKey = ByteStringSource

Header field key. This must be lower case.

lookupRequestField' :: FieldKey -> Request -> ByteStringSource

Looking up a header in Request. If the header does not exist, empty ByteString is returned.