WAI (Web Application Interface) Application for static files and CGI.
- data AppSpec = AppSpec {
- softwareName :: ByteString
- indexFile :: ByteString
- isHTML :: ByteString -> Bool
- logger :: Logger
- getFileInfo :: ByteString -> IO (Maybe FileInfo)
- type Logger = Request -> Status -> Maybe Integer -> IO ()
- data FileInfo = FileInfo {}
- data FileRoute = FileRoute {}
- fileApp :: AppSpec -> FileRoute -> Application
- data CgiRoute = CgiRoute {
- cgiSrc :: ByteString
- cgiDst :: ByteString
- cgiApp :: AppSpec -> CgiRoute -> Application
- type NumericAddress = String
- showSockAddr :: SockAddr -> NumericAddress
- type FieldKey = ByteString
- lookupRequestField :: FieldKey -> Request -> Maybe ByteString
- lookupRequestField' :: FieldKey -> Request -> ByteString
Types
AppSpec | |
|
Files
FileRoute | |
|
fileApp :: AppSpec -> 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
CgiRoute | |
|
cgiApp :: AppSpec -> CgiRoute -> ApplicationSource
Handle GET and POST for CGI.
The program to link this library must ignore SIGCHLD as follows:
installHandler sigCHLD Ignore Nothing
Utilities for logging
type NumericAddress = StringSource
A type for IP address in numeric string representation.
showSockAddr :: SockAddr -> NumericAddressSource
Convert SockAddr
to NumericAddress
. If the address is
an IPv4-embedded IPv6 address, the IPv4 is extracted.
type FieldKey = ByteStringSource
Header field key. This must be lower case.
lookupRequestField :: FieldKey -> Request -> Maybe ByteStringSource
Looking up a header in Request
.
lookupRequestField' :: FieldKey -> Request -> ByteStringSource
Looking up a header in Request
. If the header does not exist,
empty ByteString
is returned.