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

Network.Wai.Application.Classic

Contents

Description

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

Synopsis

Common

data ClassicAppSpec Source

Constructors

ClassicAppSpec 

Fields

softwareName :: ByteString

Name specified to Server: in HTTP response.

logger :: ApacheLogger

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

statusFileDir :: Path

A function to get the HTTP body of status.

data StatusInfo Source

Constructors

StatusByteString ByteString

HTTP status body is created from LB.ByteString.

StatusFile Path Integer

HTTP status body is created from FilePath.

StatusNone

No HTTP status body.

Files

data FileAppSpec Source

Constructors

FileAppSpec 

Fields

indexFile :: Path

A file name of an index file.

isHTML :: Path -> Bool

Whether this is an HTML or not.

getFileInfo :: Path -> IO (Maybe FileInfo)

A function to obtain information about a file

data FileRoute Source

Constructors

FileRoute 

Fields

fileSrc :: Path

Path prefix to be matched to rawPathInfo.

fileDst :: Path

Path prefix to an actual file system.

fileApp :: ClassicAppSpec -> FileAppSpec -> 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 :: Path

Path prefix to be matched to rawPathInfo.

cgiDst :: Path

Path prefix to an actual file system.

cgiApp :: ClassicAppSpec -> CgiRoute -> ApplicationSource

Handle GET and POST for CGI.

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

   installHandler sigCHLD Ignore Nothing

Reverse Proxy

data RevProxyAppSpec Source

Constructors

RevProxyAppSpec 

Fields

revProxyManager :: Manager

Connection manager

data RevProxyRoute Source

Constructors

RevProxyRoute 

Fields

revProxySrc :: Path

Path prefix to be matched to rawPathInfo.

revProxyDst :: Path

Destination path prefix.

revProxyDomain :: ByteString

Destination domain name.

revProxyPort :: Int

Destination port number.

revProxyApp :: ClassicAppSpec -> RevProxyAppSpec -> RevProxyRoute -> ApplicationSource

Relaying any requests as reverse proxy.

Path

data Path Source

Constructors

Path 

Instances

(+++) :: Path -> Path -> PathSource

Appending.

(</>) :: Path -> Path -> PathSource

Appending with the file separator.

(<\>) :: Path -> Path -> PathSource

Removing prefix. The prefix of the second argument is removed from the first argument.

(<.>) :: Path -> Path -> PathSource

Adding suffix.

breakAtSeparator :: Path -> (Path, Path)Source

Breaking at the first path separator.

hasTrailingPathSeparator :: Path -> BoolSource

Checking if the path ends with the path separator.