Skip to content

Commit 2176fec

Browse files
committed
config: added instances for all interpretations
1 parent 67315c4 commit 2176fec

File tree

6 files changed

+27
-2
lines changed

6 files changed

+27
-2
lines changed

servant-client/src/Servant/Client.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
798801
instance ToSample ()
799802
instance ToSample Bool

servant-foreign/src/Servant/Foreign/Internal.hs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
298305
instance HasForeign lang sublayout => HasForeign lang (HttpVersion :> sublayout) where
299306
type Foreign (HttpVersion :> sublayout) = Foreign sublayout
300307

servant-mock/src/Servant/Mock.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
163166
mockArbitrary :: (MonadIO m, Arbitrary a) => m a
164167
mockArbitrary = liftIO (generate arbitrary)
165168

servant-server/test/Servant/ServerSpec.hs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,16 @@ import Servant.Server.Internal.RoutingApplication
6060
import 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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

3435
comprehensiveAPI :: Proxy ComprehensiveAPI
3536
comprehensiveAPI = Proxy

0 commit comments

Comments
 (0)