diff --git a/servant-client/src/Servant/Client.hs b/servant-client/src/Servant/Client.hs index bab4f4a2..227eb5c5 100644 --- a/servant-client/src/Servant/Client.hs +++ b/servant-client/src/Servant/Client.hs @@ -118,6 +118,20 @@ instance (KnownSymbol capture, ToHttpApiData a, HasClient sublayout) where p = unpack (toUrlPiece val) +instance (ToHttpApiData a, HasClient sublayout) + => HasClient (CaptureAll a :> sublayout) where + + type Client (CaptureAll a :> sublayout) = + [a] -> Client sublayout + + clientWithRoute Proxy req baseurl manager vals = + clientWithRoute (Proxy :: Proxy sublayout) + (foldl' (flip appendToPath) req ps) + baseurl + manager + + where ps = map (unpack . toUrlPiece) vals + instance OVERLAPPABLE_ -- Note [Non-Empty Content Types] (MimeUnrender ct a, ReflectMethod method, cts' ~ (ct ': cts) diff --git a/servant-mock/src/Servant/Mock.hs b/servant-mock/src/Servant/Mock.hs index d2808be2..e071f800 100644 --- a/servant-mock/src/Servant/Mock.hs +++ b/servant-mock/src/Servant/Mock.hs @@ -114,6 +114,9 @@ instance (KnownSymbol path, HasMock rest) => HasMock (path :> rest) where instance (KnownSymbol s, FromHttpApiData a, HasMock rest) => HasMock (Capture s a :> rest) where mock _ = \_ -> mock (Proxy :: Proxy rest) +instance (FromHttpApiData a, HasMock rest) => HasMock (CaptureAll a :> rest) where + mock _ = \_ -> mock (Proxy :: Proxy rest) + instance (AllCTUnrender ctypes a, HasMock rest) => HasMock (ReqBody ctypes a :> rest) where mock _ = \_ -> mock (Proxy :: Proxy rest)