git.iko.soy/typeable/servant
on master help sign in
config: added instances for all interpretations
2176fecSönke Hahn
servant-client/src/Servant/Client.hs+6
@@ -417,6 +417,12 @@ instance HasClient api => HasClient (IsSecure :> api) where
417 clientWithRoute Proxy req baseurl manager =
417 clientWithRoute Proxy req baseurl manager =
418 clientWithRoute (Proxy :: Proxy api) req baseurl manager
418 clientWithRoute (Proxy :: Proxy api) req baseurl manager
419
419
420+instance HasClient subapi =>
421+ HasClient (WithNamedConfig name config subapi) where
422+
423+ type Client (WithNamedConfig name config subapi) = Client subapi
424+ clientWithRoute Proxy = clientWithRoute (Proxy :: Proxy subapi)
425+
420
426
421{- Note [Non-Empty Content Types]
427{- Note [Non-Empty Content Types]
422~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
428~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
servant-docs/src/Servant/Docs/Internal.hs+3
@@ -794,6 +794,9 @@ instance HasDocs sublayout => HasDocs (Vault :> sublayout) where
794 docsFor Proxy ep =
794 docsFor Proxy ep =
795 docsFor (Proxy :: Proxy sublayout) ep
795 docsFor (Proxy :: Proxy sublayout) ep
796
796
797+instance HasDocs sublayout => HasDocs (WithNamedConfig name config sublayout) where
798+ docsFor Proxy = docsFor (Proxy :: Proxy sublayout)
799+
797-- ToSample instances for simple types
800-- ToSample instances for simple types
798instance ToSample ()
801instance ToSample ()
799instance ToSample Bool
802instance ToSample Bool
servant-foreign/src/Servant/Foreign/Internal.hs+7
@@ -295,6 +295,13 @@ instance HasForeign lang sublayout => HasForeign lang (Vault :> sublayout) where
295 foreignFor lang Proxy req =
295 foreignFor lang Proxy req =
296 foreignFor lang (Proxy :: Proxy sublayout) req
296 foreignFor lang (Proxy :: Proxy sublayout) req
297
297
298+instance HasForeign lang sublayout =>
299+ HasForeign lang (WithNamedConfig name config sublayout) where
300+
301+ type Foreign (WithNamedConfig name config sublayout) = Foreign sublayout
302+
303+ foreignFor lang Proxy = foreignFor lang (Proxy :: Proxy sublayout)
304+
298instance HasForeign lang sublayout => HasForeign lang (HttpVersion :> sublayout) where
305instance HasForeign lang sublayout => HasForeign lang (HttpVersion :> sublayout) where
299 type Foreign (HttpVersion :> sublayout) = Foreign sublayout
306 type Foreign (HttpVersion :> sublayout) = Foreign sublayout
300
307
servant-mock/src/Servant/Mock.hs+3
@@ -160,6 +160,9 @@ instance HasMock Raw where
160
160
161 where genBody = pack <$> generate (vector 100 :: Gen [Char])
161 where genBody = pack <$> generate (vector 100 :: Gen [Char])
162
162
163+instance HasMock rest => HasMock (WithNamedConfig name config rest) where
164+ mock _ = mock (Proxy :: Proxy rest)
165+
163mockArbitrary :: (MonadIO m, Arbitrary a) => m a
166mockArbitrary :: (MonadIO m, Arbitrary a) => m a
164mockArbitrary = liftIO (generate arbitrary)
167mockArbitrary = liftIO (generate arbitrary)
165
168
servant-server/test/Servant/ServerSpec.hs+6−1
@@ -60,11 +60,16 @@ import Servant.Server.Internal.RoutingApplication
60import Servant.Server.Internal.Router
60import Servant.Server.Internal.Router
61 (tweakResponse, runRouter,
61 (tweakResponse, runRouter,
62 Router, Router'(LeafRouter))
62 Router, Router'(LeafRouter))
63+import Servant.Server.Internal.Config
64+ (Config(..), NamedConfig(..))
63
65
64-- * comprehensive api test
66-- * comprehensive api test
65
67
66-- This declaration simply checks that all instances are in place.
68-- This declaration simply checks that all instances are in place.
67−_ = serve comprehensiveAPI
69+_ = serve comprehensiveAPI comprehensiveApiConfig
70+
71+comprehensiveApiConfig :: Config '[NamedConfig "foo" '[]]
72+comprehensiveApiConfig = NamedConfig EmptyConfig :. EmptyConfig
68
73
69-- * Specs
74-- * Specs
70
75
servant/src/Servant/API/Internal/Test/ComprehensiveAPI.hs+2−1
@@ -29,7 +29,8 @@ type ComprehensiveAPI =
29 "foo" :> GET :<|>
29 "foo" :> GET :<|>
30 Vault :> GET :<|>
30 Vault :> GET :<|>
31 Verb 'POST 204 '[JSON] () :<|>
31 Verb 'POST 204 '[JSON] () :<|>
32− Verb 'POST 204 '[JSON] Int
32+ Verb 'POST 204 '[JSON] Int :<|>
33+ WithNamedConfig "foo" '[] GET
33
34
34comprehensiveAPI :: Proxy ComprehensiveAPI
35comprehensiveAPI :: Proxy ComprehensiveAPI
35comprehensiveAPI = Proxy
36comprehensiveAPI = Proxy