packages feed

wai 3.0.0 → 3.0.0.1

raw patch · 3 files changed

+36/−13 lines, 3 files

Files

Network/Wai.hs view
@@ -129,7 +129,28 @@ responseLBS :: H.Status -> H.ResponseHeaders -> L.ByteString -> Response responseLBS s h = ResponseBuilder s h . fromLazyByteString --- | Creating 'Response' from 'C.Source'.+-- | Creating 'Response' from a stream of values.+--+-- In order to allocate resources in an exception-safe manner, you can use the+-- @bracket@ pattern outside of the call to @responseStream@. As a trivial+-- example:+--+-- @+-- app :: Application+-- app req respond = bracket_+--     (putStrLn "Allocating scarce resource")+--     (putStrLn "Cleaning up")+--     $ respond $ responseStream status200 [] $ \write flush -> do+--         write $ fromByteString "Hello\n"+--         flush+--         write $ fromByteString "World\n"+-- @+--+-- Note that in some cases you can use @bracket@ from inside @responseStream@+-- as well. However, placing the call on the outside allows your status value+-- and response headers to depend on the scarce resource.+--+-- Since 3.0.0 responseStream :: H.Status                -> H.ResponseHeaders                -> StreamingBody@@ -168,7 +189,7 @@ responseHeaders (ResponseStream  _ hs _  ) = hs responseHeaders (ResponseRaw _ res)        = responseHeaders res --- | Converting the body information in 'Response' to 'Source'.+-- | Converting the body information in 'Response' to a @StreamingBody@. responseToStream :: Response                  -> ( H.Status                     , H.ResponseHeaders@@ -206,6 +227,18 @@ ----------------------------------------------------------------  -- | The WAI application.+--+-- Note that, since WAI 3.0, this type is structured in continuation passing+-- style to allow for proper safe resource handling. This was handled in the+-- past via other means (e.g., @ResourceT@). As a demonstration:+--+-- @+-- app :: Application+-- app req respond = bracket_+--     (putStrLn "Allocating scarce resource")+--     (putStrLn "Cleaning up")+--     (respond $ responseLBS status200 [] "Hello World")+-- @ type Application = Request -> (Response -> IO ResponseReceived) -> IO ResponseReceived  -- | Middleware is a component that sits between the server and application. It
Network/Wai/Internal.hs view
@@ -71,16 +71,6 @@   }   deriving (Typeable) --- | The strange structure of the third field or ResponseSource is to allow for--- exception-safe resource allocation. As an example:------ > app :: Application--- > app _ = return $ ResponseSource status200 [] $ \f -> bracket--- >     (putStrLn "Allocation" >> return 5)--- >     (\i -> putStrLn $ "Cleaning up: " ++ show i)--- >     (\_ -> f $ do--- >         yield $ Chunk $ fromByteString "Hello "--- >         yield $ Chunk $ fromByteString "World!") data Response     = ResponseFile H.Status H.ResponseHeaders FilePath (Maybe FilePart)     | ResponseBuilder H.Status H.ResponseHeaders Builder
wai.cabal view
@@ -1,5 +1,5 @@ Name:                wai-Version:             3.0.0+Version:             3.0.0.1 Synopsis:            Web Application Interface. Description:         Provides a common protocol for communication between web applications and web servers. License:             MIT