| Safe Haskell | None |
|---|
Network.Wai.Application.Classic
Description
WAI (Web Application Interface) Application for static files and CGI.
- data ClassicAppSpec = ClassicAppSpec {
- softwareName :: ByteString
- logger :: Request -> Status -> Maybe Integer -> IO ()
- statusFileDir :: Path
- defaultClassicAppSpec :: ClassicAppSpec
- data StatusInfo
- data FileAppSpec = FileAppSpec {}
- defaultFileAppSpec :: FileAppSpec
- data FileInfo = FileInfo {
- fileInfoName :: !Path
- fileInfoSize :: !Integer
- fileInfoTime :: !HTTPDate
- fileInfoDate :: !ByteString
- data FileRoute = FileRoute {}
- fileApp :: ClassicAppSpec -> FileAppSpec -> FileRoute -> Application
- data RedirectRoute = RedirectRoute {
- redirectSrc :: Path
- redirectDst :: Path
- redirectApp :: ClassicAppSpec -> RedirectRoute -> Application
- data CgiAppSpec = CgiAppSpec {}
- defaultCgiAppSpec :: CgiAppSpec
- data CgiRoute = CgiRoute {}
- cgiApp :: ClassicAppSpec -> CgiAppSpec -> CgiRoute -> Application
- data RevProxyAppSpec = RevProxyAppSpec {}
- data RevProxyRoute = RevProxyRoute {}
- revProxyApp :: ClassicAppSpec -> RevProxyAppSpec -> RevProxyRoute -> Application
- data Path = Path {}
- fromString :: IsString a => String -> a
- fromByteString :: ByteString -> Path
- (+++) :: Path -> Path -> Path
- (</>) :: Path -> Path -> Path
- (<\>) :: Path -> Path -> Path
- (<.>) :: Path -> Path -> Path
- breakAtSeparator :: Path -> (Path, Path)
- hasLeadingPathSeparator :: Path -> Bool
- hasTrailingPathSeparator :: Path -> Bool
- isSuffixOf :: Path -> Path -> Bool
- redirectHeader :: Request -> ResponseHeaders
- hostPort :: Request -> (ByteString, ByteString)
Common
data ClassicAppSpec Source
Constructors
| ClassicAppSpec | |
Fields
| |
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 |
| StatusFile Path Integer | HTTP status body is created from |
| StatusNone | No HTTP status body. |
Instances
Files
data FileAppSpec Source
Constructors
| FileAppSpec | |
defaultFileAppSpec :: FileAppSpecSource
Default value for defaultFileAppSpec. indexFile is "index.html". isHTML matches "*.html" and "*.html". getFileInfo calls getFileStatus for every request.
Constructors
| FileInfo | |
Fields
| |
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
| |
Instances
CGI
defaultCgiAppSpec :: CgiAppSpecSource
Default value for defaultCgiAppSpec. indexCgi is "index.cgi".
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
| |
data RevProxyRoute Source
Constructors
| RevProxyRoute | |
Fields
| |
Instances
revProxyApp :: ClassicAppSpec -> RevProxyAppSpec -> RevProxyRoute -> ApplicationSource
Relaying any requests as reverse proxy.
Path
Smart file path.
Constructors
| Path | |
Fields | |
fromString :: IsString a => String -> a
(</>) :: 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"
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
isSuffixOf :: Path -> Path -> BoolSource
Misc
hostPort :: Request -> (ByteString, ByteString)Source