wai/hcar-wai.tex
2016-11-01 16:05:11 +09:00

59 lines
1.8 KiB
TeX

% WAI-KW.tex
\begin{hcarentry}[updated]{WAI}
\label{wai}
\report{Kazu Yamamoto}%11/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 take this way.
However, you may want to use web application frameworks
such as Apiary, MFlow, rest, Servant, Scotty, Spock,
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, no major changes were made.
\FurtherReading
\begin{compactitem}
\item\url{https://groups.google.com/d/forum/haskell-wai}
\end{compactitem}
\end{hcarentry}