on master help sign in
Add ‘withReqManager’
commitf9409b1978d4c250f584a8809df162fae5349f91 authormrkkrp <markkarpov@opmbx.org> dateMon 7 Nov 2016, 20:52 (10 years ago) parent1caa173
1 file changed+8
Network/HTTP/Req.hs+8
Network/HTTP/Req.hs+8
@@ -105,6 +105,7 @@ module Network.HTTP.Req
105105 ( -- * Making a request
106106 -- $making-a-request
107107 req
108+ , withReqManager
108109 -- * Embedding requests into your monad
109110 -- $embedding-requests
110111 , MonadHttp (..)
@@ -418,6 +419,13 @@ globalManager = unsafePerformIO $ do
418419 newIORef manager
419420{-# NOINLINE globalManager #-}
420421
422+-- | Perform an action using global implicit 'L.Manager' that the rest of
423+-- the library uses. This allows to reuse connections that the 'L.Manager'
424+-- controls.
425+
426+withReqManager :: MonadIO m => (L.Manager -> m a) -> m a
427+withReqManager m = liftIO (readIORef globalManager) >>= m
428+
421429----------------------------------------------------------------------------
422430-- Embedding requests into your monad
423431