on warp/3.2.10 help sign in
typeable/wai/hcar-wai.tex
58 lines 1.8 kB history raw
1% WAI-KW.tex
2\begin{hcarentry}[updated]{WAI}
3\label{wai}
4\report{Kazu Yamamoto}%11/16
5\participants{Michael Snoyman, Greg Weber}
6\status{stable}
7\makeheader
9WAI (Web Application Interface) is an application interface
10between web applications and handlers in Haskell.
11The \texttt{Application} data type is defined as follows:
13\begin{verbatim}
14type Application
15 = Request
16 -> (Response -> IO ResponseReceived)
17 -> IO ResponseReceived
18\end{verbatim}
20That is, a WAI application takes two arguments: a \texttt{Request} and
21a function to send a \texttt{Response}.
22So, the typical behavior of WAI application is
23processing a request,
24generating a response and
25passing the response to the function.
27Historically speaking, this interface made possible to develop handlers
28other than HTTP.
29The WAI applications can run through FastCGI (wai-handler-fastcgi),
30run as stand-alone (wai-handler-webkit), etc.
31But the most popular handler is based on HTTP, of course.
32The major HTTP handler for WAI is Warp which now provides
33both HTTP/1.1 and HTTP/2. TLS (warp-tls) is also available.
34New transports such as
35WebSocket (wai-websocket) and Event Source (wai-extra)
36can be implemented, too.
38It is possible to develop WAI applications directly.
39For instance, Hoogle and Mighttpd2 take this way.
40However, you may want to use web application frameworks
41such as Apiary, MFlow, rest, Servant, Scotty, Spock,
42Yesod, etc.
44WAI also provides \texttt{Middleware}:
46\begin{verbatim}
47type Middleware = Application -> Application
48\end{verbatim}
50WAI middleware can inspect and transform a request, for example by automatically gzipping a response or logging a request (wai-extra).
52Since the last HCAR, no major changes were made.
54\FurtherReading
55\begin{compactitem}
56\item\url{https://groups.google.com/d/forum/haskell-wai}
57\end{compactitem}
58\end{hcarentry}