wai/hcar-wai.tex

59 lines
2.0 KiB
TeX
Raw Normal View History

2016-04-12 11:27:37 +03:00
% WAI-MW.tex
\begin{hcarentry}{WAI}
\label{wai}
2016-04-13 05:21:11 +03:00
\report{Kazu Yamamoto}%05/16
\participants{Michael Snoyman, Greg Weber}
2016-04-12 11:27:37 +03:00
\status{stable}
\makeheader
2016-04-13 05:21:11 +03:00
WAI (Web Application Interface) is an application interface
between web applications and handlers in Haskell.
The \texttt{Application} data type is defined as follows:
2016-04-12 11:27:37 +03:00
2016-04-13 05:21:11 +03:00
\begin{verbatim}
type Application = Request -> (Response -> IO ResponseReceived) -> IO ResponseReceived
\end{verbatim}
2016-04-12 11:27:37 +03:00
2016-04-13 05:21:11 +03:00
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.
2016-04-12 11:27:37 +03:00
2016-04-13 05:21:11 +03:00
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.
2016-04-12 11:27:37 +03:00
2016-04-13 05:21:11 +03:00
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.
2016-04-12 11:27:37 +03:00
2016-04-13 05:21:11 +03:00
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.
2016-04-12 11:27:37 +03:00
\FurtherReading
\begin{compactitem}
\item\url{https://groups.google.com/d/forum/haskell-wai}
\end{compactitem}
\end{hcarentry}