on develop help sign in
Using disambiguated ServiceConfig definition
2835fc2Brendan Hay
gogol/src/Network/Google/Env.hs+5−5
@@ -22,7 +22,7 @@ import Network.HTTP.Conduit
22
22
23-- | The environment containing the parameters required to make Google requests.
23-- | The environment containing the parameters required to make Google requests.
24data Env = Env
24data Env = Env
25− { _envOverride :: !(Dual (Endo Service))
25+ { _envOverride :: !(Dual (Endo ServiceConfig))
26 , _envLogger :: !Logger
26 , _envLogger :: !Logger
27 , _envManager :: !Manager
27 , _envManager :: !Manager
28 , _envStore :: !Store
28 , _envStore :: !Store
@@ -36,7 +36,7 @@ class HasEnv a where
36 {-# MINIMAL environment #-}
36 {-# MINIMAL environment #-}
37
37
38 -- | The currently applied overrides to all 'Service' configuration.
38 -- | The currently applied overrides to all 'Service' configuration.
39− envOverride :: Lens' a (Dual (Endo Service))
39+ envOverride :: Lens' a (Dual (Endo ServiceConfig))
40
40
41 -- | The function used to output log messages.
41 -- | The function used to output log messages.
42 envLogger :: Lens' a Logger
42 envLogger :: Lens' a Logger
@@ -61,7 +61,7 @@ instance HasEnv Env where
61-- To override a specific service, it's suggested you use
61-- To override a specific service, it's suggested you use
62-- either 'configure' or 'reconfigure' with a modified version of the default
62-- either 'configure' or 'reconfigure' with a modified version of the default
63-- service, such as @Network.Google.Gmail.gmailService@.
63-- service, such as @Network.Google.Gmail.gmailService@.
64−override :: HasEnv a => (Service -> Service) -> a -> a
64+override :: HasEnv a => (ServiceConfig -> ServiceConfig) -> a -> a
65override f = envOverride <>~ Dual (Endo f)
65override f = envOverride <>~ Dual (Endo f)
66
66
67-- | Configure a specific service. All requests belonging to the
67-- | Configure a specific service. All requests belonging to the
@@ -71,7 +71,7 @@ override f = envOverride <>~ Dual (Endo f)
71-- as @Network.Google.Gmail.gmailService@.
71-- as @Network.Google.Gmail.gmailService@.
72--
72--
73-- /See:/ 'reconfigure'.
73-- /See:/ 'reconfigure'.
74−configure :: HasEnv a => Service -> a -> a
74+configure :: HasEnv a => ServiceConfig -> a -> a
75configure s = override f
75configure s = override f
76 where
76 where
77 f x | on (==) _svcId s x = s
77 f x | on (==) _svcId s x = s
@@ -84,7 +84,7 @@ configure s = override f
84-- as @Network.Google.Gmail.gmailService@.
84-- as @Network.Google.Gmail.gmailService@.
85--
85--
86-- /See:/ 'configure'.
86-- /See:/ 'configure'.
87−reconfigure :: (MonadReader r m, HasEnv r) => Service -> m a -> m a
87+reconfigure :: (MonadReader r m, HasEnv r) => ServiceConfig -> m a -> m a
88reconfigure = local . configure
88reconfigure = local . configure
89
89
90-- | Scope an action such that any HTTP response will use this timeout value.
90-- | Scope an action such that any HTTP response will use this timeout value.
gogol/src/Network/Google/Internal/HTTP.hs+3−4
@@ -49,10 +49,9 @@ perform :: (MonadCatch m, MonadResource m, GoogleRequest a)
49 -> m (Either Error (Rs a))
49 -> m (Either Error (Rs a))
50perform Env{..} x = catches go handlers
50perform Env{..} x = catches go handlers
51 where
51 where
52− Request {..} = _cliRequest
52+ Request {..} = _cliRequest
53− Service {..} = _cliService
53+ ServiceConfig {..} = _cliService
54−
55− Client {..} = requestClient x
54+ Client {..} = requestClient x
56 & clientService %~ appEndo (getDual _envOverride)
55 & clientService %~ appEndo (getDual _envOverride)
57
56
58 go = liftResourceT $ do
57 go = liftResourceT $ do