@@ -4,6 +4,7 @@
4{-# LANGUAGE TypeOperators #-}
4{-# LANGUAGE TypeOperators #-}
5{-# LANGUAGE FlexibleInstances #-}
5{-# LANGUAGE FlexibleInstances #-}
6{-# LANGUAGE OverloadedStrings #-}
6{-# LANGUAGE OverloadedStrings #-}
7+{-# LANGUAGE OverlappingInstances #-}
7{-# LANGUAGE ScopedTypeVariables #-}
8{-# LANGUAGE ScopedTypeVariables #-}
8-- | This module provides 'client' which can automatically generate
9-- | This module provides 'client' which can automatically generate
9-- querying functions for each endpoint just from the type representing your
10-- querying functions for each endpoint just from the type representing your
@@ -123,6 +124,13 @@ instance (MimeUnrender ct result) => HasClient (Get (ct ': cts) result) where
123 clientWithRoute Proxy req host =
124 clientWithRoute Proxy req host =
124 performRequestCT (Proxy :: Proxy ct) H.methodGet req [200, 203] host
125 performRequestCT (Proxy :: Proxy ct) H.methodGet req [200, 203] host
127+-- | If you have a 'Get xs ()' endpoint, the client expects a 204 No Content
129+instance HasClient (Get (ct ': cts) ()) where
130+ type Client (Get (ct ': cts) ()) = BaseUrl -> EitherT ServantError IO ()
131+ clientWithRoute Proxy req host =
132+ performRequestNoBody H.methodGet req [204] host
126-- | If you use a 'Header' in one of your endpoints in your API,
134-- | If you use a 'Header' in one of your endpoints in your API,
127-- the corresponding querying function will automatically take
135-- the corresponding querying function will automatically take
128-- an additional argument of the type specified by your 'Header',
136-- an additional argument of the type specified by your 'Header',
@@ -170,6 +178,13 @@ instance (MimeUnrender ct a) => HasClient (Post (ct ': cts) a) where
170 clientWithRoute Proxy req uri =
178 clientWithRoute Proxy req uri =
171 performRequestCT (Proxy :: Proxy ct) H.methodPost req [200,201] uri
179 performRequestCT (Proxy :: Proxy ct) H.methodPost req [200,201] uri
181+-- | If you have a 'Post xs ()' endpoint, the client expects a 204 No Content
183+instance HasClient (Post (ct ': cts) ()) where
184+ type Client (Post (ct ': cts) ()) = BaseUrl -> EitherT ServantError IO ()
185+ clientWithRoute Proxy req host =
186+ void $ performRequestNoBody H.methodPost req [204] host
173-- | If you have a 'Put' endpoint in your API, the client
188-- | If you have a 'Put' endpoint in your API, the client
174-- side querying function that is created when calling 'client'
189-- side querying function that is created when calling 'client'
175-- will just require an argument that specifies the scheme, host
190-- will just require an argument that specifies the scheme, host
@@ -180,6 +195,30 @@ instance (MimeUnrender ct a) => HasClient (Put (ct ': cts) a) where
180 clientWithRoute Proxy req host =
195 clientWithRoute Proxy req host =
181 performRequestCT (Proxy :: Proxy ct) H.methodPut req [200,201] host
196 performRequestCT (Proxy :: Proxy ct) H.methodPut req [200,201] host
198+-- | If you have a 'Put xs ()' endpoint, the client expects a 204 No Content
200+instance HasClient (Put (ct ': cts) ()) where
201+ type Client (Put (ct ': cts) ()) = BaseUrl -> EitherT ServantError IO ()
202+ clientWithRoute Proxy req host =
203+ void $ performRequestNoBody H.methodPut req [204] host
205+-- | If you have a 'Patch' endpoint in your API, the client
206+-- side querying function that is created when calling 'client'
207+-- will just require an argument that specifies the scheme, host
208+-- and port to send the request to.
209+instance (MimeUnrender ct a) => HasClient (Patch (ct ': cts) a) where
210+ type Client (Patch (ct ': cts) a) = BaseUrl -> EitherT ServantError IO a
212+ clientWithRoute Proxy req host =
213+ performRequestCT (Proxy :: Proxy ct) H.methodPatch req [200,201] host
215+-- | If you have a 'Patch xs ()' endpoint, the client expects a 204 No Content
217+instance HasClient (Patch (ct ': cts) ()) where
218+ type Client (Patch (ct ': cts) ()) = BaseUrl -> EitherT ServantError IO ()
219+ clientWithRoute Proxy req host =
220+ void $ performRequestNoBody H.methodPatch req [204] host
183-- | If you use a 'QueryParam' in one of your endpoints in your API,
222-- | If you use a 'QueryParam' in one of your endpoints in your API,
184-- the corresponding querying function will automatically take
223-- the corresponding querying function will automatically take
185-- an additional argument of the type specified by your 'QueryParam',
224-- an additional argument of the type specified by your 'QueryParam',
@@ -222,7 +261,7 @@ instance (KnownSymbol sym, ToText a, HasClient sublayout)
223-- | If you use a 'QueryParams' in one of your endpoints in your API,
262-- | If you use a 'QueryParams' in one of your endpoints in your API,
224-- the corresponding querying function will automatically take
263-- the corresponding querying function will automatically take
225−-- an additional argument, a list of values of the type specified
264+-- an additional argument, a list of values of the type specified
226-- by your 'QueryParams'.
265-- by your 'QueryParams'.
228-- If you give an empty list, nothing will be added to the query string.
267-- If you give an empty list, nothing will be added to the query string.