on develop help sign in
Using ServiceConfig inplace of ambiguous Service
26772c7Brendan Hay
gogol/src/Network/Google/Env.hs+4−4
@@ -29,7 +29,7 @@ import Network.HTTP.Conduit
29
29
30-- | The environment containing the parameters required to make Google requests.
30-- | The environment containing the parameters required to make Google requests.
31data Env (s :: [Symbol]) = Env
31data Env (s :: [Symbol]) = Env
32− { _envOverride :: !(Dual (Endo Service))
32+ { _envOverride :: !(Dual (Endo ServiceConfig))
33 , _envLogger :: !Logger
33 , _envLogger :: !Logger
34 , _envManager :: !Manager
34 , _envManager :: !Manager
35 , _envStore :: !(Store s)
35 , _envStore :: !(Store s)
@@ -68,7 +68,7 @@ instance HasEnv s (Env s) where
68-- To override a specific service, it's suggested you use
68-- To override a specific service, it's suggested you use
69-- either 'configure' or 'reconfigure' with a modified version of the default
69-- either 'configure' or 'reconfigure' with a modified version of the default
70-- service, such as @Network.Google.Gmail.gmailService@.
70-- service, such as @Network.Google.Gmail.gmailService@.
71−override :: HasEnv s a => (Service -> Service) -> a -> a
71+override :: HasEnv s a => (Service -> ServiceConfig) -> a -> a
72override f = envOverride <>~ Dual (Endo f)
72override f = envOverride <>~ Dual (Endo f)
73
73
74-- | Configure a specific service. All requests belonging to the
74-- | Configure a specific service. All requests belonging to the
@@ -78,7 +78,7 @@ override f = envOverride <>~ Dual (Endo f)
78-- as @Network.Google.Gmail.gmailService@.
78-- as @Network.Google.Gmail.gmailService@.
79--
79--
80-- /See:/ 'reconfigure'.
80-- /See:/ 'reconfigure'.
81−configure :: HasEnv s a => Service -> a -> a
81+configure :: HasEnv s a => ServiceConfig -> a -> a
82configure s = override f
82configure s = override f
83 where
83 where
84 f x | on (==) _svcId s x = s
84 f x | on (==) _svcId s x = s
@@ -91,7 +91,7 @@ configure s = override f
91-- as @Network.Google.Gmail.gmailService@.
91-- as @Network.Google.Gmail.gmailService@.
92--
92--
93-- /See:/ 'configure'.
93-- /See:/ 'configure'.
94−reconfigure :: (MonadReader r m, HasEnv s r) => Service -> m a -> m a
94+reconfigure :: (MonadReader r m, HasEnv s r) => ServiceConfig -> m a -> m a
95reconfigure = local . configure
95reconfigure = local . configure
96
96
97-- | Scope an action such that any HTTP response will use this timeout value.
97-- | 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, Allow s, 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