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

Safe HaskellNone

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.

dater :: IO ZonedDate

A function to get the HTTP body of status.

statusFileDir :: Path
 

defaultClassicAppSpec :: ClassicAppSpecSource

Default value for ClassicAppSpec. softwareName is "Classic". logger does not log at all. 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

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.

defaultFileAppSpec :: FileAppSpecSource

Default value for defaultFileAppSpec. indexFile is "index.html". isHTML matches "*.html" and "*.html". getFileInfo calls getFileStatus for every request.

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

Redirect

data RedirectRoute Source

Constructors

RedirectRoute 

Fields

redirectSrc :: Path

Path prefix to be matched to rawPathInfo.

redirectDst :: Path

Path prefix to an actual file system.

CGI

data CgiAppSpec Source

Constructors

CgiAppSpec 

Fields

indexCgi :: Path

A file name of the default CGI.

defaultCgiAppSpec :: CgiAppSpecSource

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.

Instances

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