git.iko.soy/typeable/servant
on master help sign in
config: added instances for all interpretations
commit2176fecfda33e4d200fef3b4c920cf0f2321ca74 authorSönke Hahn <soenkehahn@gmail.com> dateMon 18 Jan 2016, 21:27 (11 years ago) parent67315c4
6 files changed+27−2
servant-client/src/Servant/Client.hs+6 servant-docs/src/Servant/Docs/Internal.hs+3 servant-foreign/src/Servant/Foreign/Internal.hs+7 servant-mock/src/Servant/Mock.hs+3 servant-server/test/Servant/ServerSpec.hs+6−1 servant/src/Servant/API/Internal/Test/ComprehensiveAPI.hs+2−1
servant-client/src/Servant/Client.hs+6
@@ -417,6 +417,12 @@ instance HasClient api => HasClient (IsSecure :> api) where
417417 clientWithRoute Proxy req baseurl manager =
418418 clientWithRoute (Proxy :: Proxy api) req baseurl manager
419419
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+
420426
421427{- Note [Non-Empty Content Types]
422428~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
servant-docs/src/Servant/Docs/Internal.hs+3
@@ -794,6 +794,9 @@ instance HasDocs sublayout => HasDocs (Vault :> sublayout) where
794794 docsFor Proxy ep =
795795 docsFor (Proxy :: Proxy sublayout) ep
796796
797+instance HasDocs sublayout => HasDocs (WithNamedConfig name config sublayout) where
798+ docsFor Proxy = docsFor (Proxy :: Proxy sublayout)
799+
797800-- ToSample instances for simple types
798801instance ToSample ()
799802instance ToSample Bool
servant-foreign/src/Servant/Foreign/Internal.hs+7
@@ -295,6 +295,13 @@ instance HasForeign lang sublayout => HasForeign lang (Vault :> sublayout) where
295295 foreignFor lang Proxy req =
296296 foreignFor lang (Proxy :: Proxy sublayout) req
297297
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+
298305instance HasForeign lang sublayout => HasForeign lang (HttpVersion :> sublayout) where
299306 type Foreign (HttpVersion :> sublayout) = Foreign sublayout
300307
servant-mock/src/Servant/Mock.hs+3
@@ -160,6 +160,9 @@ instance HasMock Raw where
160160
161161 where genBody = pack <$> generate (vector 100 :: Gen [Char])
162162
163+instance HasMock rest => HasMock (WithNamedConfig name config rest) where
164+ mock _ = mock (Proxy :: Proxy rest)
165+
163166mockArbitrary :: (MonadIO m, Arbitrary a) => m a
164167mockArbitrary = liftIO (generate arbitrary)
165168
servant-server/test/Servant/ServerSpec.hs+6−1
@@ -60,11 +60,16 @@ import Servant.Server.Internal.RoutingApplication
6060import Servant.Server.Internal.Router
6161 (tweakResponse, runRouter,
6262 Router, Router'(LeafRouter))
63+import Servant.Server.Internal.Config
64+ (Config(..), NamedConfig(..))
6365
6466-- * comprehensive api test
6567
6668-- 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
6873
6974-- * Specs
7075
servant/src/Servant/API/Internal/Test/ComprehensiveAPI.hs+2−1
@@ -29,7 +29,8 @@ type ComprehensiveAPI =
2929 "foo" :> GET :<|>
3030 Vault :> GET :<|>
3131 Verb 'POST 204 '[JSON] () :<|>
32− Verb 'POST 204 '[JSON] Int
32+ Verb 'POST 204 '[JSON] Int :<|>
33+ WithNamedConfig "foo" '[] GET
3334
3435comprehensiveAPI :: Proxy ComprehensiveAPI
3536comprehensiveAPI = Proxy