on master help sign in
Clean up interface and Haddocks
bf5c8fbAndrew Pritchard
wai/Network/Wai/HTTP2.hs+21−13
@@ -1,13 +1,20 @@
1{-# LANGUAGE OverloadedStrings, RankNTypes #-}
1{-# LANGUAGE OverloadedStrings, RankNTypes #-}
2{-# LANGUAGE CPP #-}
2{-# LANGUAGE CPP #-}
3module Network.Wai.HTTP2
3module Network.Wai.HTTP2
4− ( Chunk(..)
4+ (
5+ -- * Applications
5− , HTTP2Application
6+ HTTP2Application
6− , PushPromise(..)
7− , RespondFunc
8 , Responder
7 , Responder
8+ , Body
9+ , Chunk(..)
10+ , BodyOf
11+ , PushFunc
9 , Trailers
12 , Trailers
13+ -- * Server push
14+ , PushPromise(..)
10 , promiseHeaders
15 , promiseHeaders
16+ -- * Conveniences
17+ , SimpleBody
11 , promoteApplication
18 , promoteApplication
12 , responder
19 , responder
13 , streamFilePart
20 , streamFilePart
@@ -58,15 +65,16 @@ type Body a = BodyOf Chunk a
58-- 'Network.Wai.StreamingBody' with @c ~ Builder@ and @a ~ ()@.
65-- 'Network.Wai.StreamingBody' with @c ~ Builder@ and @a ~ ()@.
59type BodyOf c a = (c -> IO ()) -> IO () -> IO a
66type BodyOf c a = (c -> IO ()) -> IO () -> IO a
60
67
61−-- | A function given to an 'HTTP2Application' used to send the response. This
68+-- | The result of an 'HTTP2Application'; or, alternately, an application
69+-- that's independent of the request. This is a continuation-passing style
70+-- function that first provides a response by calling the given respond
71+-- function, then returns the request's 'Trailers'.
72+--
62−-- is similar to the respond function in 'Network.Wai.Application', but the
73+-- The respond function is similar to the one in 'Network.Wai.Application', but
74+-- it only takes a streaming body, the status and headers are curried, and it
63−-- status and headers are curried, and it passes on any result value from the
75+-- passes on any result value from the stream body.
64−-- stream body.
65−type RespondFunc = forall a. H.Status -> H.ResponseHeaders -> Body a -> IO a
76+type Responder = (forall a. H.Status -> H.ResponseHeaders -> Body a -> IO a)
66−
67−-- | A continuation-passing style function that provides a response by calling
68−-- the 'RespondFunc', then returns the request's 'Trailers'.
69−type Responder = RespondFunc -> IO Trailers
77+ -> IO Trailers
70
78
71-- | A function given to an 'HTTP2Application' to initiate a server-pushed
79-- | A function given to an 'HTTP2Application' to initiate a server-pushed
72-- stream. Its argument is the same as the result of an 'HTTP2Application', so
80-- stream. Its argument is the same as the result of an 'HTTP2Application', so
warp/Network/Wai/Handler/Warp/HTTP2/Worker.hs+5−4
@@ -27,17 +27,18 @@ import Network.Wai.Handler.Warp.HTTP2.EncodeFrame
27import Network.Wai.Handler.Warp.HTTP2.Manager
27import Network.Wai.Handler.Warp.HTTP2.Manager
28import Network.Wai.Handler.Warp.HTTP2.Types
28import Network.Wai.Handler.Warp.HTTP2.Types
29import Network.Wai.Handler.Warp.IORef
29import Network.Wai.Handler.Warp.IORef
30−import Network.Wai.HTTP2 (Chunk(..), HTTP2Application, PushPromise, Responder, RespondFunc)
30+import Network.Wai.HTTP2 (Chunk(..), HTTP2Application, PushPromise, Responder)
31import qualified Network.Wai.Handler.Warp.Settings as S
31import qualified Network.Wai.Handler.Warp.Settings as S
32import qualified Network.Wai.Handler.Warp.Timeout as T
32import qualified Network.Wai.Handler.Warp.Timeout as T
33
33
34----------------------------------------------------------------
34----------------------------------------------------------------
35
35
36−-- | An 'HTTP2Application' takes a 'RespondFunc'; this type implements that by
36+-- | An 'HTTP2Application' takes a function of status, headers, and body; this
37−-- currying some internal arguments.
37+-- type implements that by currying some internal arguments.
38--
38--
39-- This is the argument to a 'Responder'.
39-- This is the argument to a 'Responder'.
40−type Respond = IO () -> Stream -> TBQueue Sequence -> RespondFunc
40+type Respond = forall a. IO () -> Stream -> TBQueue Sequence
41+ -> H.Status -> H.ResponseHeaders -> Body a -> IO a
41
42
42-- | This function is passed to workers.
43-- | This function is passed to workers.
43-- They also pass responses from 'HTTP2Application's to this function.
44-- They also pass responses from 'HTTP2Application's to this function.