@@ -1,5 +1,6 @@
1{-# LANGUAGE Rank2Types #-}
1{-# LANGUAGE Rank2Types #-}
2{-# LANGUAGE ExistentialQuantification #-}
2{-# LANGUAGE ExistentialQuantification #-}
3+{-# LANGUAGE DeriveDataTypeable #-}
5This module defines a generic web application interface. It is a common
6This module defines a generic web application interface. It is a common
@@ -74,6 +75,7 @@ import qualified Data.ByteString.Char8 as B8
74import qualified Data.ByteString.Lazy as L
75import qualified Data.ByteString.Lazy as L
75import Data.Char (toLower)
76import Data.Char (toLower)
76import Data.String (IsString (..))
77import Data.String (IsString (..))
78+import Data.Typeable (Typeable)
78-- | HTTP request method. Since the HTTP protocol allows arbitrary request
80-- | HTTP request method. Since the HTTP protocol allows arbitrary request
79-- methods, we leave this open as a 'B.ByteString'. Please note the request
81-- methods, we leave this open as a 'B.ByteString'. Please note the request
@@ -257,6 +259,7 @@ data Request = Request
257 -- | The client\'s host information.
259 -- | The client\'s host information.
258 , remoteHost :: B.ByteString
260 , remoteHost :: B.ByteString
261-- | The response body returned to the server from the application. We provide
264-- | The response body returned to the server from the application. We provide
262-- three separate constructors as optimizations:
265-- three separate constructors as optimizations:
@@ -274,6 +277,7 @@ data Request = Request
274data ResponseBody = ResponseFile FilePath
277data ResponseBody = ResponseFile FilePath
275 | ResponseEnumerator Enumerator
278 | ResponseEnumerator Enumerator
276 | ResponseLBS L.ByteString
279 | ResponseLBS L.ByteString
278data Response = Response
282data Response = Response
279 { status :: Status
283 { status :: Status
@@ -284,6 +288,7 @@ data Response = Response
284 -- whatever means it wishes. If 'Right', it will call the 'Enumerator'.
288 -- whatever means it wishes. If 'Right', it will call the 'Enumerator'.
285 , responseBody :: ResponseBody
289 , responseBody :: ResponseBody
288type Application = Request -> IO Response
293type Application = Request -> IO Response