@@ -52,16 +52,17 @@ import Servant.Common.Req
52-- > getAllBooks :: BaseUrl -> EitherT String IO [Book]
52-- > getAllBooks :: BaseUrl -> EitherT String IO [Book]
53-- > postNewBook :: Book -> BaseUrl -> EitherT String IO Book
53-- > postNewBook :: Book -> BaseUrl -> EitherT String IO Book
54-- > (getAllBooks :<|> postNewBook) = client myApi
54-- > (getAllBooks :<|> postNewBook) = client myApi
55−client :: HasClient layout => Proxy layout -> Client layout
55+client :: HasClient layout => Proxy layout -> BaseUrl -> Client layout
56−client p = clientWithRoute p defReq
56+client p baseurl = clientWithRoute p defReq baseurl
58-- | This class lets us define how each API combinator
58-- | This class lets us define how each API combinator
59-- influences the creation of an HTTP request. It's mostly
59-- influences the creation of an HTTP request. It's mostly
60-- an internal class, you can just use 'client'.
60-- an internal class, you can just use 'client'.
61class HasClient layout where
61class HasClient layout where
62 type Client layout :: *
62 type Client layout :: *
63− clientWithRoute :: Proxy layout -> Req -> Client layout
63+ clientWithRoute :: Proxy layout -> Req -> BaseUrl -> Client layout
65+{-type Client layout = Client layout-}
66-- | A client querying function for @a ':<|>' b@ will actually hand you
67-- | A client querying function for @a ':<|>' b@ will actually hand you
67-- one function for querying @a@ and another one for querying @b@,
68-- one function for querying @a@ and another one for querying @b@,
@@ -78,9 +79,9 @@ class HasClient layout where
78-- > (getAllBooks :<|> postNewBook) = client myApi
79-- > (getAllBooks :<|> postNewBook) = client myApi
79instance (HasClient a, HasClient b) => HasClient (a :<|> b) where
80instance (HasClient a, HasClient b) => HasClient (a :<|> b) where
80 type Client (a :<|> b) = Client a :<|> Client b
81 type Client (a :<|> b) = Client a :<|> Client b
81− clientWithRoute Proxy req =
82+ clientWithRoute Proxy req baseurl =
82− clientWithRoute (Proxy :: Proxy a) req :<|>
83+ clientWithRoute (Proxy :: Proxy a) req baseurl :<|>
83− clientWithRoute (Proxy :: Proxy b) req
84+ clientWithRoute (Proxy :: Proxy b) req baseurl
85-- | If you use a 'Capture' in one of your endpoints in your API,
86-- | If you use a 'Capture' in one of your endpoints in your API,
86-- the corresponding querying function will automatically take
87-- the corresponding querying function will automatically take
@@ -107,9 +108,10 @@ instance (KnownSymbol capture, ToText a, HasClient sublayout)
107 type Client (Capture capture a :> sublayout) =
108 type Client (Capture capture a :> sublayout) =
108 a -> Client sublayout
109 a -> Client sublayout
110− clientWithRoute Proxy req val =
111+ clientWithRoute Proxy req baseurl val =
111− clientWithRoute (Proxy :: Proxy sublayout) $
112+ clientWithRoute (Proxy :: Proxy sublayout)
112− appendToPath p req
113+ (appendToPath p req)
114 where p = unpack (toText val)
116 where p = unpack (toText val)
@@ -122,9 +124,9 @@ instance
122 {-# OVERLAPPABLE #-}
124 {-# OVERLAPPABLE #-}
124 (MimeUnrender ct a) => HasClient (Delete (ct ': cts) a) where
126 (MimeUnrender ct a) => HasClient (Delete (ct ': cts) a) where
125− type Client (Delete (ct ': cts) a) = BaseUrl -> EitherT ServantError IO a
127+ type Client (Delete (ct ': cts) a) = EitherT ServantError IO a
126− clientWithRoute Proxy req host =
128+ clientWithRoute Proxy req baseurl =
127− snd <$> performRequestCT (Proxy :: Proxy ct) H.methodDelete req [200, 202] host
129+ snd <$> performRequestCT (Proxy :: Proxy ct) H.methodDelete req [200, 202] baseurl
129-- | If you have a 'Delete xs ()' endpoint, the client expects a 204 No Content
131-- | If you have a 'Delete xs ()' endpoint, the client expects a 204 No Content
130-- HTTP header.
132-- HTTP header.
@@ -133,9 +135,9 @@ instance
133 {-# OVERLAPPING #-}
135 {-# OVERLAPPING #-}
135 HasClient (Delete (ct ': cts) ()) where
137 HasClient (Delete (ct ': cts) ()) where
136− type Client (Delete (ct ': cts) ()) = BaseUrl -> EitherT ServantError IO ()
138+ type Client (Delete (ct ': cts) ()) = EitherT ServantError IO ()
137− clientWithRoute Proxy req host =
139+ clientWithRoute Proxy req baseurl =
138− void $ performRequestNoBody H.methodDelete req [204] host
140+ void $ performRequestNoBody H.methodDelete req [204] baseurl
140-- | If you have a 'Delete xs (Headers ls x)' endpoint, the client expects the
142-- | If you have a 'Delete xs (Headers ls x)' endpoint, the client expects the
141-- corresponding headers.
143-- corresponding headers.
@@ -145,14 +147,13 @@ instance
146 ( MimeUnrender ct a, BuildHeadersTo ls
148 ( MimeUnrender ct a, BuildHeadersTo ls
147 ) => HasClient (Delete (ct ': cts) (Headers ls a)) where
149 ) => HasClient (Delete (ct ': cts) (Headers ls a)) where
148− type Client (Delete (ct ': cts) (Headers ls a)) = BaseUrl -> EitherT ServantError IO (Headers ls a)
150+ type Client (Delete (ct ': cts) (Headers ls a)) = EitherT ServantError IO (Headers ls a)
149− clientWithRoute Proxy req host = do
151+ clientWithRoute Proxy req baseurl = do
150− (hdrs, resp) <- performRequestCT (Proxy :: Proxy ct) H.methodDelete req [200, 202] host
152+ (hdrs, resp) <- performRequestCT (Proxy :: Proxy ct) H.methodDelete req [200, 202] baseurl
151 return $ Headers { getResponse = resp
153 return $ Headers { getResponse = resp
152 , getHeadersHList = buildHeadersTo hdrs
154 , getHeadersHList = buildHeadersTo hdrs
156-- | If you have a 'Get' endpoint in your API, the client
157-- | If you have a 'Get' endpoint in your API, the client
157-- side querying function that is created when calling 'client'
158-- side querying function that is created when calling 'client'
158-- will just require an argument that specifies the scheme, host
159-- will just require an argument that specifies the scheme, host
@@ -162,9 +163,9 @@ instance
162 {-# OVERLAPPABLE #-}
163 {-# OVERLAPPABLE #-}
164 (MimeUnrender ct result) => HasClient (Get (ct ': cts) result) where
165 (MimeUnrender ct result) => HasClient (Get (ct ': cts) result) where
165− type Client (Get (ct ': cts) result) = BaseUrl -> EitherT ServantError IO result
166+ type Client (Get (ct ': cts) result) = EitherT ServantError IO result
166− clientWithRoute Proxy req host =
167+ clientWithRoute Proxy req baseurl =
167− snd <$> performRequestCT (Proxy :: Proxy ct) H.methodGet req [200, 203] host
168+ snd <$> performRequestCT (Proxy :: Proxy ct) H.methodGet req [200, 203] baseurl
169-- | If you have a 'Get xs ()' endpoint, the client expects a 204 No Content
170-- | If you have a 'Get xs ()' endpoint, the client expects a 204 No Content
170-- HTTP status.
171-- HTTP status.
@@ -173,9 +174,9 @@ instance
173 {-# OVERLAPPING #-}
174 {-# OVERLAPPING #-}
175 HasClient (Get (ct ': cts) ()) where
176 HasClient (Get (ct ': cts) ()) where
176− type Client (Get (ct ': cts) ()) = BaseUrl -> EitherT ServantError IO ()
177+ type Client (Get (ct ': cts) ()) = EitherT ServantError IO ()
177− clientWithRoute Proxy req host =
178+ clientWithRoute Proxy req baseurl =
178− performRequestNoBody H.methodGet req [204] host
179+ performRequestNoBody H.methodGet req [204] baseurl
180-- | If you have a 'Get xs (Headers ls x)' endpoint, the client expects the
181-- | If you have a 'Get xs (Headers ls x)' endpoint, the client expects the
181-- corresponding headers.
182-- corresponding headers.
@@ -185,9 +186,9 @@ instance
186 ( MimeUnrender ct a, BuildHeadersTo ls
187 ( MimeUnrender ct a, BuildHeadersTo ls
187 ) => HasClient (Get (ct ': cts) (Headers ls a)) where
188 ) => HasClient (Get (ct ': cts) (Headers ls a)) where
188− type Client (Get (ct ': cts) (Headers ls a)) = BaseUrl -> EitherT ServantError IO (Headers ls a)
189+ type Client (Get (ct ': cts) (Headers ls a)) = EitherT ServantError IO (Headers ls a)
189− clientWithRoute Proxy req host = do
190+ clientWithRoute Proxy req baseurl = do
190− (hdrs, resp) <- performRequestCT (Proxy :: Proxy ct) H.methodGet req [200, 203, 204] host
191+ (hdrs, resp) <- performRequestCT (Proxy :: Proxy ct) H.methodGet req [200, 203, 204] baseurl
191 return $ Headers { getResponse = resp
192 return $ Headers { getResponse = resp
192 , getHeadersHList = buildHeadersTo hdrs
193 , getHeadersHList = buildHeadersTo hdrs
@@ -223,9 +224,13 @@ instance (KnownSymbol sym, ToText a, HasClient sublayout)
223 type Client (Header sym a :> sublayout) =
224 type Client (Header sym a :> sublayout) =
224 Maybe a -> Client sublayout
225 Maybe a -> Client sublayout
226− clientWithRoute Proxy req mval =
227+ clientWithRoute Proxy req baseurl mval =
227− clientWithRoute (Proxy :: Proxy sublayout) $
228+ clientWithRoute (Proxy :: Proxy sublayout)
228− maybe req (\value -> Servant.Common.Req.addHeader hname value req) mval
230+ (\value -> Servant.Common.Req.addHeader hname value req)
230 where hname = symbolVal (Proxy :: Proxy sym)
235 where hname = symbolVal (Proxy :: Proxy sym)
@@ -238,10 +243,9 @@ instance
238 {-# OVERLAPPABLE #-}
243 {-# OVERLAPPABLE #-}
240 (MimeUnrender ct a) => HasClient (Post (ct ': cts) a) where
245 (MimeUnrender ct a) => HasClient (Post (ct ': cts) a) where
241− type Client (Post (ct ': cts) a) = BaseUrl -> EitherT ServantError IO a
246+ type Client (Post (ct ': cts) a) = EitherT ServantError IO a
243− clientWithRoute Proxy req uri =
247+ clientWithRoute Proxy req baseurl =
244− snd <$> performRequestCT (Proxy :: Proxy ct) H.methodPost req [200,201] uri
248+ snd <$> performRequestCT (Proxy :: Proxy ct) H.methodPost req [200,201] baseurl
246-- | If you have a 'Post xs ()' endpoint, the client expects a 204 No Content
250-- | If you have a 'Post xs ()' endpoint, the client expects a 204 No Content
247-- HTTP header.
251-- HTTP header.
@@ -250,9 +254,9 @@ instance
250 {-# OVERLAPPING #-}
254 {-# OVERLAPPING #-}
252 HasClient (Post (ct ': cts) ()) where
256 HasClient (Post (ct ': cts) ()) where
253− type Client (Post (ct ': cts) ()) = BaseUrl -> EitherT ServantError IO ()
257+ type Client (Post (ct ': cts) ()) = EitherT ServantError IO ()
254− clientWithRoute Proxy req host =
258+ clientWithRoute Proxy req baseurl =
255− void $ performRequestNoBody H.methodPost req [204] host
259+ void $ performRequestNoBody H.methodPost req [204] baseurl
257-- | If you have a 'Post xs (Headers ls x)' endpoint, the client expects the
261-- | If you have a 'Post xs (Headers ls x)' endpoint, the client expects the
258-- corresponding headers.
262-- corresponding headers.
@@ -262,9 +266,9 @@ instance
263 ( MimeUnrender ct a, BuildHeadersTo ls
267 ( MimeUnrender ct a, BuildHeadersTo ls
264 ) => HasClient (Post (ct ': cts) (Headers ls a)) where
268 ) => HasClient (Post (ct ': cts) (Headers ls a)) where
265− type Client (Post (ct ': cts) (Headers ls a)) = BaseUrl -> EitherT ServantError IO (Headers ls a)
269+ type Client (Post (ct ': cts) (Headers ls a)) = EitherT ServantError IO (Headers ls a)
266− clientWithRoute Proxy req host = do
270+ clientWithRoute Proxy req baseurl = do
267− (hdrs, resp) <- performRequestCT (Proxy :: Proxy ct) H.methodPost req [200, 201] host
271+ (hdrs, resp) <- performRequestCT (Proxy :: Proxy ct) H.methodPost req [200, 201] baseurl
268 return $ Headers { getResponse = resp
272 return $ Headers { getResponse = resp
269 , getHeadersHList = buildHeadersTo hdrs
273 , getHeadersHList = buildHeadersTo hdrs
@@ -278,10 +282,9 @@ instance
278 {-# OVERLAPPABLE #-}
282 {-# OVERLAPPABLE #-}
280 (MimeUnrender ct a) => HasClient (Put (ct ': cts) a) where
284 (MimeUnrender ct a) => HasClient (Put (ct ': cts) a) where
281− type Client (Put (ct ': cts) a) = BaseUrl -> EitherT ServantError IO a
285+ type Client (Put (ct ': cts) a) = EitherT ServantError IO a
283− clientWithRoute Proxy req host =
286+ clientWithRoute Proxy req baseurl =
284− snd <$> performRequestCT (Proxy :: Proxy ct) H.methodPut req [200,201] host
287+ snd <$> performRequestCT (Proxy :: Proxy ct) H.methodPut req [200,201] baseurl
286-- | If you have a 'Put xs ()' endpoint, the client expects a 204 No Content
289-- | If you have a 'Put xs ()' endpoint, the client expects a 204 No Content
287-- HTTP header.
290-- HTTP header.
@@ -290,9 +293,9 @@ instance
290 {-# OVERLAPPING #-}
293 {-# OVERLAPPING #-}
292 HasClient (Put (ct ': cts) ()) where
295 HasClient (Put (ct ': cts) ()) where
293− type Client (Put (ct ': cts) ()) = BaseUrl -> EitherT ServantError IO ()
296+ type Client (Put (ct ': cts) ()) = EitherT ServantError IO ()
294− clientWithRoute Proxy req host =
297+ clientWithRoute Proxy req baseurl =
295− void $ performRequestNoBody H.methodPut req [204] host
298+ void $ performRequestNoBody H.methodPut req [204] baseurl
297-- | If you have a 'Put xs (Headers ls x)' endpoint, the client expects the
300-- | If you have a 'Put xs (Headers ls x)' endpoint, the client expects the
298-- corresponding headers.
301-- corresponding headers.
@@ -302,9 +305,9 @@ instance
303 ( MimeUnrender ct a, BuildHeadersTo ls
306 ( MimeUnrender ct a, BuildHeadersTo ls
304 ) => HasClient (Put (ct ': cts) (Headers ls a)) where
307 ) => HasClient (Put (ct ': cts) (Headers ls a)) where
305− type Client (Put (ct ': cts) (Headers ls a)) = BaseUrl -> EitherT ServantError IO (Headers ls a)
308+ type Client (Put (ct ': cts) (Headers ls a)) = EitherT ServantError IO (Headers ls a)
306− clientWithRoute Proxy req host = do
309+ clientWithRoute Proxy req baseurl = do
307− (hdrs, resp) <- performRequestCT (Proxy :: Proxy ct) H.methodPut req [200, 201] host
310+ (hdrs, resp) <- performRequestCT (Proxy :: Proxy ct) H.methodPut req [200, 201] baseurl
308 return $ Headers { getResponse = resp
311 return $ Headers { getResponse = resp
309 , getHeadersHList = buildHeadersTo hdrs
312 , getHeadersHList = buildHeadersTo hdrs
@@ -318,10 +321,9 @@ instance
318 {-# OVERLAPPABLE #-}
321 {-# OVERLAPPABLE #-}
320 (MimeUnrender ct a) => HasClient (Patch (ct ': cts) a) where
323 (MimeUnrender ct a) => HasClient (Patch (ct ': cts) a) where
321− type Client (Patch (ct ': cts) a) = BaseUrl -> EitherT ServantError IO a
324+ type Client (Patch (ct ': cts) a) = EitherT ServantError IO a
323− clientWithRoute Proxy req host =
325+ clientWithRoute Proxy req baseurl =
324− snd <$> performRequestCT (Proxy :: Proxy ct) H.methodPatch req [200,201] host
326+ snd <$> performRequestCT (Proxy :: Proxy ct) H.methodPatch req [200,201] baseurl
326-- | If you have a 'Patch xs ()' endpoint, the client expects a 204 No Content
328-- | If you have a 'Patch xs ()' endpoint, the client expects a 204 No Content
327-- HTTP header.
329-- HTTP header.
@@ -330,9 +332,9 @@ instance
330 {-# OVERLAPPING #-}
332 {-# OVERLAPPING #-}
332 HasClient (Patch (ct ': cts) ()) where
334 HasClient (Patch (ct ': cts) ()) where
333− type Client (Patch (ct ': cts) ()) = BaseUrl -> EitherT ServantError IO ()
335+ type Client (Patch (ct ': cts) ()) = EitherT ServantError IO ()
334− clientWithRoute Proxy req host =
336+ clientWithRoute Proxy req baseurl =
335− void $ performRequestNoBody H.methodPatch req [204] host
337+ void $ performRequestNoBody H.methodPatch req [204] baseurl
337-- | If you have a 'Patch xs (Headers ls x)' endpoint, the client expects the
339-- | If you have a 'Patch xs (Headers ls x)' endpoint, the client expects the
338-- corresponding headers.
340-- corresponding headers.
@@ -342,9 +344,9 @@ instance
343 ( MimeUnrender ct a, BuildHeadersTo ls
345 ( MimeUnrender ct a, BuildHeadersTo ls
344 ) => HasClient (Patch (ct ': cts) (Headers ls a)) where
346 ) => HasClient (Patch (ct ': cts) (Headers ls a)) where
345− type Client (Patch (ct ': cts) (Headers ls a)) = BaseUrl -> EitherT ServantError IO (Headers ls a)
347+ type Client (Patch (ct ': cts) (Headers ls a)) = EitherT ServantError IO (Headers ls a)
346− clientWithRoute Proxy req host = do
348+ clientWithRoute Proxy req baseurl = do
347− (hdrs, resp) <- performRequestCT (Proxy :: Proxy ct) H.methodPatch req [200, 201, 204] host
349+ (hdrs, resp) <- performRequestCT (Proxy :: Proxy ct) H.methodPatch req [200, 201, 204] baseurl
348 return $ Headers { getResponse = resp
350 return $ Headers { getResponse = resp
349 , getHeadersHList = buildHeadersTo hdrs
351 , getHeadersHList = buildHeadersTo hdrs
@@ -381,9 +383,13 @@ instance (KnownSymbol sym, ToText a, HasClient sublayout)
381 Maybe a -> Client sublayout
383 Maybe a -> Client sublayout
383 -- if mparam = Nothing, we don't add it to the query string
385 -- if mparam = Nothing, we don't add it to the query string
384− clientWithRoute Proxy req mparam =
386+ clientWithRoute Proxy req baseurl mparam =
385− clientWithRoute (Proxy :: Proxy sublayout) $
387+ clientWithRoute (Proxy :: Proxy sublayout)
386− maybe req (flip (appendToQueryString pname) req . Just) mparamText
389+ (flip (appendToQueryString pname) req . Just)
388 where pname = cs pname'
394 where pname = cs pname'
389 pname' = symbolVal (Proxy :: Proxy sym)
395 pname' = symbolVal (Proxy :: Proxy sym)
@@ -422,9 +428,13 @@ instance (KnownSymbol sym, ToText a, HasClient sublayout)
422 type Client (QueryParams sym a :> sublayout) =
428 type Client (QueryParams sym a :> sublayout) =
423 [a] -> Client sublayout
429 [a] -> Client sublayout
425− clientWithRoute Proxy req paramlist =
431+ clientWithRoute Proxy req baseurl paramlist =
426− clientWithRoute (Proxy :: Proxy sublayout) $
432+ clientWithRoute (Proxy :: Proxy sublayout)
427− foldl' (\ req' -> maybe req' (flip (appendToQueryString pname) req' . Just)) req paramlist'
433+ (foldl' (\ req' -> maybe req' (flip (appendToQueryString pname) req' . Just))
429 where pname = cs pname'
439 where pname = cs pname'
430 pname' = symbolVal (Proxy :: Proxy sym)
440 pname' = symbolVal (Proxy :: Proxy sym)
@@ -457,11 +467,13 @@ instance (KnownSymbol sym, HasClient sublayout)
457 type Client (QueryFlag sym :> sublayout) =
467 type Client (QueryFlag sym :> sublayout) =
458 Bool -> Client sublayout
468 Bool -> Client sublayout
460− clientWithRoute Proxy req flag =
470+ clientWithRoute Proxy req baseurl flag =
461− clientWithRoute (Proxy :: Proxy sublayout) $
471+ clientWithRoute (Proxy :: Proxy sublayout)
462− if flag
472+ (if flag
463− then appendToQueryString paramname Nothing req
473+ then appendToQueryString paramname Nothing req
464− else req
474+ else req
466 where paramname = cs $ symbolVal (Proxy :: Proxy sym)
478 where paramname = cs $ symbolVal (Proxy :: Proxy sym)
@@ -497,9 +509,13 @@ instance (KnownSymbol sym, ToText a, HasClient sublayout)
497 Maybe a -> Client sublayout
509 Maybe a -> Client sublayout
499 -- if mparam = Nothing, we don't add it to the query string
511 -- if mparam = Nothing, we don't add it to the query string
500− clientWithRoute Proxy req mparam =
512+ clientWithRoute Proxy req baseurl mparam =
501− clientWithRoute (Proxy :: Proxy sublayout) $
513+ clientWithRoute (Proxy :: Proxy sublayout)
502− maybe req (flip (appendToMatrixParams pname . Just) req) mparamText
515+ (flip (appendToMatrixParams pname . Just) req)
504 where pname = symbolVal (Proxy :: Proxy sym)
520 where pname = symbolVal (Proxy :: Proxy sym)
505 mparamText = fmap (cs . toText) mparam
521 mparamText = fmap (cs . toText) mparam
@@ -537,9 +553,13 @@ instance (KnownSymbol sym, ToText a, HasClient sublayout)
537 type Client (MatrixParams sym a :> sublayout) =
553 type Client (MatrixParams sym a :> sublayout) =
538 [a] -> Client sublayout
554 [a] -> Client sublayout
540− clientWithRoute Proxy req paramlist =
556+ clientWithRoute Proxy req baseurl paramlist =
541− clientWithRoute (Proxy :: Proxy sublayout) $
557+ clientWithRoute (Proxy :: Proxy sublayout)
542− foldl' (\ req' value -> maybe req' (flip (appendToMatrixParams pname) req' . Just . cs) value) req paramlist'
558+ (foldl' (\ req' value -> maybe req' (flip (appendToMatrixParams pname) req' . Just . cs) value)
544 where pname = cs pname'
564 where pname = cs pname'
545 pname' = symbolVal (Proxy :: Proxy sym)
565 pname' = symbolVal (Proxy :: Proxy sym)
@@ -572,22 +592,24 @@ instance (KnownSymbol sym, HasClient sublayout)
572 type Client (MatrixFlag sym :> sublayout) =
592 type Client (MatrixFlag sym :> sublayout) =
573 Bool -> Client sublayout
593 Bool -> Client sublayout
575− clientWithRoute Proxy req flag =
595+ clientWithRoute Proxy req baseurl flag =
576− clientWithRoute (Proxy :: Proxy sublayout) $
596+ clientWithRoute (Proxy :: Proxy sublayout)
577− if flag
597+ (if flag
578− then appendToMatrixParams paramname Nothing req
598+ then appendToMatrixParams paramname Nothing req
579− else req
599+ else req
581 where paramname = cs $ symbolVal (Proxy :: Proxy sym)
603 where paramname = cs $ symbolVal (Proxy :: Proxy sym)
583-- | Pick a 'Method' and specify where the server you want to query is. You get
605-- | Pick a 'Method' and specify where the server you want to query is. You get
584-- back the full `Response`.
606-- back the full `Response`.
585instance HasClient Raw where
607instance HasClient Raw where
586− type Client Raw = H.Method -> BaseUrl -> EitherT ServantError IO (Int, ByteString, MediaType, [HTTP.Header], Response ByteString)
608+ type Client Raw = H.Method -> EitherT ServantError IO (Int, ByteString, MediaType, [HTTP.Header], Response ByteString)
588− clientWithRoute :: Proxy Raw -> Req -> Client Raw
610+ clientWithRoute :: Proxy Raw -> Req -> BaseUrl -> Client Raw
589− clientWithRoute Proxy req httpMethod host = do
611+ clientWithRoute Proxy req baseurl httpMethod = do
590− performRequest httpMethod req (const True) host
612+ performRequest httpMethod req (const True) baseurl
592-- | If you use a 'ReqBody' in one of your endpoints in your API,
614-- | If you use a 'ReqBody' in one of your endpoints in your API,
593-- the corresponding querying function will automatically take
615-- the corresponding querying function will automatically take
@@ -613,18 +635,23 @@ instance (MimeRender ct a, HasClient sublayout)
613 type Client (ReqBody (ct ': cts) a :> sublayout) =
635 type Client (ReqBody (ct ': cts) a :> sublayout) =
614 a -> Client sublayout
636 a -> Client sublayout
616− clientWithRoute Proxy req body =
638+ clientWithRoute Proxy req baseurl body =
617− clientWithRoute (Proxy :: Proxy sublayout) $ do
639+ clientWithRoute (Proxy :: Proxy sublayout)
618− let ctProxy = Proxy :: Proxy ct
640+ (let ctProxy = Proxy :: Proxy ct
619− setRQBody (mimeRender ctProxy body) (contentType ctProxy) req
641+ in setRQBody (mimeRender ctProxy body)
642+ (contentType ctProxy)
621-- | Make the querying function append @path@ to the request path.
647-- | Make the querying function append @path@ to the request path.
622instance (KnownSymbol path, HasClient sublayout) => HasClient (path :> sublayout) where
648instance (KnownSymbol path, HasClient sublayout) => HasClient (path :> sublayout) where
623 type Client (path :> sublayout) = Client sublayout
649 type Client (path :> sublayout) = Client sublayout
625− clientWithRoute Proxy req =
651+ clientWithRoute Proxy req baseurl =
626− clientWithRoute (Proxy :: Proxy sublayout) $
652+ clientWithRoute (Proxy :: Proxy sublayout)
627− appendToPath p req
653+ (appendToPath p req)
629 where p = symbolVal (Proxy :: Proxy path)
656 where p = symbolVal (Proxy :: Proxy path)