forked from yesodweb/wai
-
Notifications
You must be signed in to change notification settings - Fork 1
/
hcar-wai.tex
54 lines (44 loc) · 1.9 KB
/
hcar-wai.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
% WAI-KW.tex
\begin{hcarentry}{WAI}
\label{wai}
\report{Kazu Yamamoto}%05/18
\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, WAI started using Builder of ByteString instead of
Builder of blaze-builder. Because they are identical, no backward
compatibility issue happens.
\FurtherReading
\begin{compactitem}
\item\url{https://groups.google.com/d/forum/haskell-wai}
\end{compactitem}
\end{hcarentry}