wai/hcar-wai.tex
2016-04-13 11:21:11 +09:00

59 lines
2.0 KiB
TeX

% WAI-MW.tex
\begin{hcarentry}{WAI}
\label{wai}
\report{Kazu Yamamoto}%05/16
\participants{Michael Snoyman, Greg Weber}
\status{stable}
\makeheader
WAI (Web Application Interface) is an application interface
between web applications and handlers in Haskell.
The \texttt{Application} data type is defined as follows:
\begin{verbatim}
type Application = Request -> (Response -> IO ResponseReceived) -> IO ResponseReceived
\end{verbatim}
That is, a WAI application takes two arguments: a \texttt{Request} and
a function to send a \texttt{Response}.
So, the typical behavior of WAI application is
processing a request,
generating a response and
passing the response to the function.
Historically speaking, this interface made possible to develop handlers
other than HTTP.
The WAI applications can run through FastCGI (wai-handler-fastcgi),
run as stand-alone (wai-handler-webkit), etc.
But the most popular handler is based on HTTP, of course.
The major HTTP handler for WAI is Warp which now provides
both HTTP/1.1 and HTTP/2. TLS (warp-tls) is also available.
New transports such as
WebSocket (wai-websocket) and Event Source (wai-extra)
can be implemented, too.
It is possible to develop WAI applications directly.
For instance, Hoogle and Mighttpd2~\cref{mighttpd2} take this way.
However, you may want to use web application frameworks
such as Apiary, MFlow~\cref{mflow}, rest, Servant, Scotty~\cref{scotty}, Spock,
Yesod~\cref{yesod}, etc.
WAI also provides \texttt{Middleware}:
\begin{verbatim}
type Middleware = Application -> Application
\end{verbatim}
WAI middleware can inspect and transform a request, for example by automatically gzipping a response or logging a request (wai-extra).
Since the last HCAR, WAI has successfully released version 3.2,
which removes the experimental HTTP/2 module and some APIs.
We bumped the version from 3.0 to 3.2 for consistency with
Warp 3.2.
\FurtherReading
\begin{compactitem}
\item\url{https://groups.google.com/d/forum/haskell-wai}
\end{compactitem}
\end{hcarentry}