wai-app-file-cgi-0.5.8: File/CGI/Rev Proxy App of WAI

Safe HaskellSafe-Infered

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 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 FileInfo

A function to obtain information about a file. If information is not obtained, an IO exception should be raised.

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 CgiAppSpec Source

Constructors

CgiAppSpec 

Fields

indexCgi :: Path

A file name of the default 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 -> CgiAppSpec -> 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

Smart file path.

Constructors

Path 

Instances

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

Appending.

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

Appending with the file separator.

>>> "/foo" </> "bar"
"/foo/bar"
>>> "/foo/" </> "bar"
"/foo/bar"
>>> "/foo" </> "/bar"
"/foo/bar"
>>> "/foo/" </> "/bar"
"/foo/bar"

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

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

>>> "foobar" <\> "foo"
"bar"
>>> "foo" <\> "foobar"
""
>>> "foobar" <\> "baz"
"bar"

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

Adding suffix.

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

Breaking at the first path separator.

>>> breakAtSeparator "/foo/bar/baz"
("","/foo/bar/baz")
>>> breakAtSeparator "foo/bar/baz"
("foo","/bar/baz")
>>> breakAtSeparator "foo"
("foo","")

hasLeadingPathSeparator :: Path -> BoolSource

Checking if the path ends with the path separator.

>>> hasLeadingPathSeparator "/foo/bar"
True
>>> hasLeadingPathSeparator "foo/bar"
False

hasTrailingPathSeparator :: Path -> BoolSource

Checking if the path ends with the path separator.

>>> hasTrailingPathSeparator "/foo/bar/"
True
>>> hasTrailingPathSeparator "/foo/bar"
False

Misc