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

Safe HaskellNone
LanguageHaskell2010

Network.Wai.Application.Classic

Contents

Description

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

Synopsis

Common

data ClassicAppSpec Source #

Constructors

ClassicAppSpec 

Fields

defaultClassicAppSpec :: ClassicAppSpec Source #

Default value for ClassicAppSpec. softwareName is "Classic". dater calls epochTime for every request. statusFileDir is "/usr/local/share/html/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

defaultFileAppSpec :: FileAppSpec Source #

Default value for defaultFileAppSpec. indexFile is "index.html". isHTML matches "*.html" and "*.html".

data FileRoute Source #

Constructors

FileRoute 

Fields

fileApp :: ClassicAppSpec -> FileAppSpec -> FileRoute -> Application Source #

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:.

Redirect

data RedirectRoute Source #

Constructors

RedirectRoute 

Fields

CGI

data CgiAppSpec Source #

Constructors

CgiAppSpec 

Fields

defaultCgiAppSpec :: CgiAppSpec Source #

Default value for defaultCgiAppSpec. indexCgi is "index.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 -> Application Source #

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

data RevProxyRoute Source #

Constructors

RevProxyRoute 

Fields

revProxyApp :: ClassicAppSpec -> RevProxyAppSpec -> RevProxyRoute -> Application Source #

Relaying any requests as reverse proxy.

Path

type Path = ByteString Source #

File path.

(</>) :: Path -> Path -> Path Source #

Appending with the file separator.

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

(<\>) :: Path -> Path -> Path Source #

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

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

(<.>) :: Path -> Path -> Path Source #

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 -> Bool Source #

Checking if the path ends with the path separator.

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

hasTrailingPathSeparator :: Path -> Bool Source #

Checking if the path ends with the path separator.

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

Misc