Safe Haskell | Safe-Infered |
---|
WAI (Web Application Interface) Application for static files and CGI.
- data ClassicAppSpec = ClassicAppSpec {}
- data StatusInfo
- data FileAppSpec = FileAppSpec {}
- data FileInfo = FileInfo {}
- data FileRoute = FileRoute {}
- fileApp :: ClassicAppSpec -> FileAppSpec -> FileRoute -> Application
- data CgiAppSpec = 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)
- hasTrailingPathSeparator :: Path -> Bool
- isSuffixOf :: Path -> Path -> Bool
- redirectHeader :: Request -> ResponseHeaders
Common
data ClassicAppSpec Source
ClassicAppSpec | |
|
data StatusInfo Source
StatusByteString ByteString | HTTP status body is created from |
StatusFile Path Integer | HTTP status body is created from |
StatusNone | No HTTP status body. |
Files
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
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
RevProxyAppSpec | |
|
data RevProxyRoute Source
RevProxyRoute | |
|
revProxyApp :: ClassicAppSpec -> RevProxyAppSpec -> RevProxyRoute -> ApplicationSource
Relaying any requests as reverse proxy.
Path
Smart file path.
fromString :: IsString a => String -> a
(</>) :: Path -> Path -> PathSource
Appending with the file separator.
>>>
"/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","")
hasTrailingPathSeparator :: Path -> BoolSource
Checking if the path ends with the path separator.
>>>
hasTrailingPathSeparator "/foo/bar/"
True>>>
hasTrailingPathSeparator "/foo/bar"
False
isSuffixOf :: Path -> Path -> BoolSource