on master help sign in
Add ‘withReqManager’
f9409b1mrkkrp
Network/HTTP/Req.hs+8
@@ -105,6 +105,7 @@ module Network.HTTP.Req
105 ( -- * Making a request
105 ( -- * Making a request
106 -- $making-a-request
106 -- $making-a-request
107 req
107 req
108+ , withReqManager
108 -- * Embedding requests into your monad
109 -- * Embedding requests into your monad
109 -- $embedding-requests
110 -- $embedding-requests
110 , MonadHttp (..)
111 , MonadHttp (..)
@@ -418,6 +419,13 @@ globalManager = unsafePerformIO $ do
418 newIORef manager
419 newIORef manager
419{-# NOINLINE globalManager #-}
420{-# NOINLINE globalManager #-}
420
421
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+
421----------------------------------------------------------------------------
429----------------------------------------------------------------------------
422-- Embedding requests into your monad
430-- Embedding requests into your monad
423
431