Support CaptureAll in servant-client and servant-mock
This commit is contained in:
parent
e23245c5bf
commit
a61d62dd6f
2 changed files with 17 additions and 0 deletions
|
@ -118,6 +118,20 @@ instance (KnownSymbol capture, ToHttpApiData a, HasClient sublayout)
|
||||||
|
|
||||||
where p = unpack (toUrlPiece val)
|
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_
|
instance OVERLAPPABLE_
|
||||||
-- Note [Non-Empty Content Types]
|
-- Note [Non-Empty Content Types]
|
||||||
(MimeUnrender ct a, ReflectMethod method, cts' ~ (ct ': cts)
|
(MimeUnrender ct a, ReflectMethod method, cts' ~ (ct ': cts)
|
||||||
|
|
|
@ -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
|
instance (KnownSymbol s, FromHttpApiData a, HasMock rest) => HasMock (Capture s a :> rest) where
|
||||||
mock _ = \_ -> mock (Proxy :: Proxy rest)
|
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
|
instance (AllCTUnrender ctypes a, HasMock rest) => HasMock (ReqBody ctypes a :> rest) where
|
||||||
mock _ = \_ -> mock (Proxy :: Proxy rest)
|
mock _ = \_ -> mock (Proxy :: Proxy rest)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue