@@ -1,17 +1,14 @@
11{-# LANGUAGE AllowAmbiguousTypes #-}
22{-# LANGUAGE CPP #-}
33{-# LANGUAGE DataKinds #-}
4−{-# LANGUAGE DefaultSignatures #-}
5−{-# LANGUAGE ExtendedDefaultRules #-}
64{-# LANGUAGE FlexibleContexts #-}
75{-# LANGUAGE FlexibleInstances #-}
8−{-# LANGUAGE FunctionalDependencies #-}
96{-# LANGUAGE GeneralizedNewtypeDeriving #-}
107{-# LANGUAGE InstanceSigs #-}
118{-# LANGUAGE MultiParamTypeClasses #-}
129{-# LANGUAGE OverloadedStrings #-}
1310{-# LANGUAGE PolyKinds #-}
14−{-# LANGUAGE RecordWildCards #-}
11+{-# LANGUAGE Rank2Types #-}
1512{-# LANGUAGE ScopedTypeVariables #-}
1613{-# LANGUAGE TupleSections #-}
1714{-# LANGUAGE TypeFamilies #-}
@@ -29,7 +26,9 @@
2926module Servant.Reflex
3027 ( client
3128 , clientWithOpts
29+ , clientWithOptsAndResultHandler
3230 , clientWithRoute
31+ , clientWithRouteAndResultHandler
3332 , BuildHeaderKeysTo(..)
3433 , toHeaders
3534 , HasClient
@@ -40,56 +39,56 @@ module Servant.Reflex
4039
4140------------------------------------------------------------------------------
4241import Control.Applicative
43−import qualified Data.ByteString as BS
44−import qualified Data.ByteString.Lazy as BL
45−import Data.CaseInsensitive (mk)
42+import qualified Data.CaseInsensitive as CI
4643import Data.Functor.Identity
47−import Data.Kind (Type)
48−import qualified Data.Map as Map
49−import Data.Monoid ((<>))
50−import Data.Proxy (Proxy (..))
51−import qualified Data.Set as Set
52−import Data.Text (Text)
53−import qualified Data.Text as T
54−import qualified Data.Text.Encoding as E
55−import qualified Data.Text.Lazy as TL
56−import GHC.Exts (Constraint)
57−import GHC.TypeLits (KnownSymbol, symbolVal)
58−import GHCJS.DOM.Types (Blob, Document, FormData)
59−import Servant.API ((:<|>) (..), (:>), Accept (..),
60− BasicAuth, BasicAuthData,
61− BuildHeadersTo (..), Capture,
62− FormUrlEncoded, Header, Headers (..),
63− HttpVersion, IsSecure, JSON,
64− MimeRender (..), NoContent,
65− OctetStream, PlainText, QueryFlag,
66− QueryParam, QueryParams, Raw,
67− ReflectMethod (..), RemoteHost,
68− ReqBody, ToHttpApiData (..), Vault,
69− Verb, contentType)
70−import qualified Servant.Auth as Auth
71−
72−import Reflex.Dom.Core (Dynamic, Event, IsXhrPayload, Reflex,
73− XhrRequest (..), XhrResponse (..),
74− XhrResponseHeaders (..),
75− attachPromptlyDynWith, constDyn, ffor,
76− fmapMaybe, leftmost,
77− performRequestsAsync)
44+import qualified Data.Map as Map
45+import Data.Monoid ((<>))
46+import Data.Proxy (Proxy (..))
47+import qualified Data.Set as Set
48+import Data.Text (Text)
49+import qualified Data.Text as T
50+import qualified Data.Text.Encoding as E
51+import GHC.Exts (Constraint)
52+import GHC.TypeLits (KnownSymbol, symbolVal)
53+import Servant.API ((:<|>) (..), (:>), BasicAuth,
54+ BasicAuthData, BuildHeadersTo (..),
55+ Capture, Header, Headers (..),
56+ HttpVersion, IsSecure,
57+ MimeRender (..), MimeUnrender,
58+ NoContent, QueryFlag, QueryParam,
59+ QueryParams, Raw, ReflectMethod (..),
60+ RemoteHost, ReqBody,
61+ ToHttpApiData (..), Vault, Verb,
62+ contentType)
63+import Servant.API.Description (Summary)
64+import qualified Servant.Auth as Auth
65+
66+import Reflex.Dom.Core (Dynamic, Event, Reflex,
67+ XhrRequest (..), XhrResponse (..),
68+ XhrResponseHeaders (..),
69+ attachPromptlyDynWith, constDyn, ffor,
70+ fmapMaybe, leftmost,
71+ performRequestsAsync)
7872------------------------------------------------------------------------------
79−import Servant.Common.BaseUrl (BaseUrl (..), Scheme (..),
80− SupportsServantReflex, baseUrlWidget,
81− showBaseUrl)
82−import Servant.Common.Req (ClientOptions (..), MimeUnrender (..),
83− QParam (..), QueryPart (..), Req (..),
84− ReqResult (..), addHeader, authData,
85− defReq, defaultClientOptions,
86− evalResponse, performRequestsCT,
87− performRequestsNoBody,
88− performSomeRequestsAsync,
89− prependToPathParts, qParamToQueryPart,
90− qParams, reqBody, reqFailure,
91− reqMethod, reqSuccess, reqTag,
92− respHeaders, response, withCredentials)
73+import Servant.Common.BaseUrl (BaseUrl(..), Scheme(..), baseUrlWidget,
74+ showBaseUrl,
75+ SupportsServantReflex)
76+import Servant.Common.Req (ClientOptions(..),
77+ defaultClientOptions,
78+ Req, ReqResult(..), QParam(..),
79+ QueryPart(..), addHeader, authData,
80+ defReq, evalResponse, prependToPathParts,
81+ -- performRequestCT,
82+ performRequestsCT,
83+ -- performRequestNoBody,
84+ performRequestsNoBody,
85+ performSomeRequestsAsync,
86+ qParamToQueryPart, reqBody,
87+ reqSuccess, reqFailure,
88+ reqMethod, respHeaders,
89+ response,
90+ reqTag,
91+ qParams, withCredentials)
9392
9493
9594-- * Accessing APIs as a Client
@@ -104,7 +103,7 @@ import Servant.Common.Req (ClientOptions (..), MimeUnrender (..),
104103-- >
105104-- > getAllBooks :: Event t l -> m (Event t (l, ReqResult [Book]))
106105-- > postNewBook :: Dynamic t (Maybe Book) -> Event t l
107−-- -> m (Event t (l, ReqResult Book)))
106+-- > -> m (Event t (l, ReqResult Book)))
108107-- > (getAllBooks :<|> postNewBook) = client myApi host
109108-- > where host = constDyn $ BaseUrl Http "localhost" 8080
110109client
@@ -126,21 +125,53 @@ clientWithOpts
126125 -> Client t m layout tag
127126clientWithOpts p q t baseurl = clientWithRoute p q t defReq baseurl
128127
128+-- | Like 'clientWithOpts' but allows passing a function which will process the
129+-- result event in some way. This can be used to handle errors in a uniform way
130+-- across call sites.
131+clientWithOptsAndResultHandler
132+ :: (HasClient t m layout tag)
133+ => Proxy layout
134+ -> Proxy m
135+ -> Proxy tag
136+ -> Dynamic t BaseUrl
137+ -> ClientOptions
138+ -> (forall a. Event t (ReqResult tag a) -> m (Event t (ReqResult tag a)))
139+ -> Client t m layout tag
140+clientWithOptsAndResultHandler p q t = clientWithRouteAndResultHandler p q t defReq
141+
129142
130143-- | This class lets us define how each API combinator
131144-- influences the creation of an HTTP request. It's mostly
132145-- an internal class, you can just use 'client'.
133−class HasClient t m layout (tag :: Type) where
134− type Client t m layout tag :: Type
135− clientWithRoute :: Proxy layout -> Proxy m -> Proxy tag -> Req t -> Dynamic t BaseUrl -> ClientOptions -> Client t m layout tag
146+class Monad m => HasClient t m layout (tag :: *) where
147+ type Client t m layout tag :: *
148+ clientWithRoute
149+ :: Proxy layout
150+ -> Proxy m
151+ -> Proxy tag
152+ -> Req t
153+ -> Dynamic t BaseUrl
154+ -> ClientOptions
155+ -> Client t m layout tag
156+ clientWithRoute l m t r b o = clientWithRouteAndResultHandler l m t r b o return
157+
158+ clientWithRouteAndResultHandler
159+ :: Proxy layout
160+ -> Proxy m
161+ -> Proxy tag
162+ -> Req t
163+ -> Dynamic t BaseUrl
164+ -> ClientOptions
165+ -> (forall a. Event t (ReqResult tag a) -> m (Event t (ReqResult tag a)))
166+ -> Client t m layout tag
136167
137168
138169instance (HasClient t m a tag, HasClient t m b tag) => HasClient t m (a :<|> b) tag where
139170 type Client t m (a :<|> b) tag = Client t m a tag :<|> Client t m b tag
140171
141− clientWithRoute Proxy q pTag req baseurl opts =
142− clientWithRoute (Proxy :: Proxy a) q pTag req baseurl opts :<|>
143− clientWithRoute (Proxy :: Proxy b) q pTag req baseurl opts
172+ clientWithRouteAndResultHandler Proxy q pTag req baseurl opts wrap =
173+ clientWithRouteAndResultHandler (Proxy :: Proxy a) q pTag req baseurl opts wrap :<|>
174+ clientWithRouteAndResultHandler (Proxy :: Proxy b) q pTag req baseurl opts wrap
144175
145176
146177-- Capture. Example:
@@ -161,11 +192,9 @@ instance (SupportsServantReflex t m, ToHttpApiData a, HasClient t m sublayout ta
161192 type Client t m (Capture capture a :> sublayout) tag =
162193 Dynamic t (Either Text a) -> Client t m sublayout tag
163194
164− clientWithRoute Proxy q t req baseurl opts val =
165− clientWithRoute (Proxy :: Proxy sublayout)
166− q t
167− (prependToPathParts p req)
168− baseurl opts
195+ clientWithRouteAndResultHandler Proxy q t req baseurl opts wrap val =
196+ clientWithRouteAndResultHandler
197+ (Proxy :: Proxy sublayout) q t (prependToPathParts p req) baseurl opts wrap
169198 where p = (fmap . fmap) (toUrlPiece) val
170199
171200
@@ -178,8 +207,8 @@ instance {-# OVERLAPPABLE #-}
178207 Event t tag -> m (Event t (ReqResult tag a))
179208 -- TODO how to access input types here?
180209 -- ExceptT ServantError IO a
181− clientWithRoute Proxy _ _ req baseurl opts trigs =
182− fmap runIdentity <$> performRequestsCT (Proxy :: Proxy ct) method (constDyn $ Identity $ req') baseurl opts trigs
210+ clientWithRouteAndResultHandler Proxy _ _ req baseurl opts wrap trigs =
211+ wrap =<< fmap runIdentity <$> performRequestsCT (Proxy :: Proxy ct) method (constDyn $ Identity $ req') baseurl opts trigs
183212 where method = E.decodeUtf8 $ reflectMethod (Proxy :: Proxy method)
184213 req' = req { reqMethod = method }
185214
@@ -192,29 +221,33 @@ instance {-# OVERLAPPING #-}
192221 Event t tag -> m (Event t (ReqResult tag NoContent))
193222 -- TODO: how to access input types here?
194223 -- ExceptT ServantError IO NoContent
195− clientWithRoute Proxy _ _ req baseurl opts =
196− (fmap . fmap) runIdentity . performRequestsNoBody method (constDyn $ Identity req) baseurl opts
224+ clientWithRouteAndResultHandler Proxy _ _ req baseurl opts wrap trigs =
225+ wrap =<< fmap runIdentity <$> performRequestsNoBody method (constDyn $ Identity req) baseurl opts trigs
197226 where method = E.decodeUtf8 $ reflectMethod (Proxy :: Proxy method)
198227
199228
200229toHeaders :: BuildHeadersTo ls => ReqResult tag a -> ReqResult tag (Headers ls a)
201230toHeaders r =
202− let toBS = E.encodeUtf8
203− hdrs = maybe []
204− (\xhr -> fmap (\(h,v) -> (mk (toBS h), toBS v))
231+ let hdrs = maybe []
232+ (\xhr -> fmap (\(h,v) -> (CI.map E.encodeUtf8 h, E.encodeUtf8 v))
205233 (Map.toList $ _xhrResponse_headers xhr))
206234 (response r)
207235 in ffor r $ \a -> Headers {getResponse = a ,getHeadersHList = buildHeadersTo hdrs}
208236
237+
209238class BuildHeaderKeysTo hs where
210− buildHeaderKeysTo :: Proxy hs -> [T.Text]
239+ buildHeaderKeysTo :: Proxy hs -> [CI.CI T.Text]
211240
212241instance {-# OVERLAPPABLE #-} BuildHeaderKeysTo '[]
213242 where buildHeaderKeysTo _ = []
214243
215244instance {-# OVERLAPPABLE #-} (BuildHeaderKeysTo xs, KnownSymbol h)
216245 => BuildHeaderKeysTo ((Header h v) ': xs) where
217− buildHeaderKeysTo _ = T.pack (symbolVal (Proxy :: Proxy h)) : buildHeaderKeysTo (Proxy :: Proxy xs)
246+ buildHeaderKeysTo _ =
247+ let
248+ thisKey = CI.mk $ T.pack (symbolVal (Proxy :: Proxy h))
249+ in thisKey : buildHeaderKeysTo (Proxy :: Proxy xs)
250+
218251
219252-- HEADERS Verb (Content) --
220253-- Headers combinator not treated in fully general case,
@@ -229,10 +262,10 @@ instance {-# OVERLAPPABLE #-}
229262 ) => HasClient t m (Verb method status cts' (Headers ls a)) tag where
230263 type Client t m (Verb method status cts' (Headers ls a)) tag =
231264 Event t tag -> m (Event t (ReqResult tag (Headers ls a)))
232− clientWithRoute Proxy _ _ req baseurl opts trigs = do
265+ clientWithRouteAndResultHandler Proxy _ _ req baseurl opts wrap trigs = do
233266 let method = E.decodeUtf8 $ reflectMethod (Proxy :: Proxy method)
234267 resp <- fmap runIdentity <$> performRequestsCT (Proxy :: Proxy ct) method (constDyn $ Identity req') baseurl opts trigs
235− return $ toHeaders <$> resp
268+ wrap $ toHeaders <$> resp
236269 where req' = req { respHeaders =
237270 OnlyHeaders (Set.fromList (buildHeaderKeysTo (Proxy :: Proxy ls)))
238271 }
@@ -245,10 +278,10 @@ instance {-# OVERLAPPABLE #-}
245278 ) => HasClient t m (Verb method status cts (Headers ls NoContent)) tag where
246279 type Client t m (Verb method status cts (Headers ls NoContent)) tag
247280 = Event t tag -> m (Event t (ReqResult tag (Headers ls NoContent)))
248− clientWithRoute Proxy _ _ req baseurl opts trigs = do
281+ clientWithRouteAndResultHandler Proxy _ _ req baseurl opts wrap trigs = do
249282 let method = E.decodeUtf8 $ reflectMethod (Proxy :: Proxy method)
250283 resp <- fmap runIdentity <$> performRequestsNoBody method (constDyn $ Identity req') baseurl opts trigs
251− return $ toHeaders <$> resp
284+ wrap $ toHeaders <$> resp
252285 where req' = req {respHeaders =
253286 OnlyHeaders (Set.fromList (buildHeaderKeysTo (Proxy :: Proxy ls)))
254287 }
@@ -275,11 +308,11 @@ instance (KnownSymbol sym, ToHttpApiData a,
275308 type Client t m (Header sym a :> sublayout) tag =
276309 Dynamic t (Either Text a) -> Client t m sublayout tag
277310
278− clientWithRoute Proxy q t req baseurl opts eVal =
279− clientWithRoute (Proxy :: Proxy sublayout)
280− q t
281− (Servant.Common.Req.addHeader hname eVal req)
282− baseurl opts
311+ clientWithRouteAndResultHandler Proxy q t req baseurl opts wrap eVal =
312+ clientWithRouteAndResultHandler
313+ (Proxy :: Proxy sublayout) q t
314+ (Servant.Common.Req.addHeader hname eVal req)
315+ baseurl opts wrap
283316 where hname = T.pack $ symbolVal (Proxy :: Proxy sym)
284317
285318
@@ -293,8 +326,21 @@ instance HasClient t m sublayout tag
293326 type Client t m (HttpVersion :> sublayout) tag =
294327 Client t m sublayout tag
295328
296− clientWithRoute Proxy q t =
297− clientWithRoute (Proxy :: Proxy sublayout) q t
329+ clientWithRouteAndResultHandler Proxy =
330+ clientWithRouteAndResultHandler (Proxy :: Proxy sublayout)
331+
332+-- | Using a 'Summary' combinator in your API doesn't affect the client
333+-- functions.
334+instance (HasClient t m sublayout tag, KnownSymbol sym)
335+ => HasClient t m (Summary sym :> sublayout) tag where
336+
337+ type Client t m (Summary sym :> sublayout) tag =
338+ Client t m sublayout tag
339+
340+ clientWithRouteAndResultHandler Proxy =
341+ clientWithRouteAndResultHandler (Proxy :: Proxy sublayout)
342+
343+
298344
299345
300346-- | If you use a 'QueryParam' in one of your endpoints in your API,
@@ -330,9 +376,9 @@ instance (KnownSymbol sym, ToHttpApiData a, HasClient t m sublayout tag, Reflex
330376 Dynamic t (QParam a) -> Client t m sublayout tag
331377
332378 -- if mparam = Nothing, we don't add it to the query string
333− clientWithRoute Proxy q t req baseurl opts mparam =
334− clientWithRoute (Proxy :: Proxy sublayout) q t
335− (req {qParams = paramPair : qParams req}) baseurl opts
379+ clientWithRouteAndResultHandler Proxy q t req baseurl opts wrap mparam =
380+ clientWithRouteAndResultHandler (Proxy :: Proxy sublayout) q t
381+ (req {qParams = paramPair : qParams req}) baseurl opts wrap
336382
337383 where pname = symbolVal (Proxy :: Proxy sym)
338384 --p prm = QueryPartParam $ (fmap . fmap) (toQueryParam) prm
@@ -376,8 +422,8 @@ instance (KnownSymbol sym, ToHttpApiData a, HasClient t m sublayout tag, Reflex
376422 type Client t m (QueryParams sym a :> sublayout) tag =
377423 Dynamic t [a] -> Client t m sublayout tag
378424
379− clientWithRoute Proxy q t req baseurl opts paramlist =
380− clientWithRoute (Proxy :: Proxy sublayout) q t req' baseurl opts
425+ clientWithRouteAndResultHandler Proxy q t req baseurl opts wrap paramlist =
426+ clientWithRouteAndResultHandler (Proxy :: Proxy sublayout) q t req' baseurl opts wrap
381427
382428 where req' = req { qParams = (T.pack pname, params') : qParams req }
383429 pname = symbolVal (Proxy :: Proxy sym)
@@ -416,8 +462,8 @@ instance (KnownSymbol sym, HasClient t m sublayout tag, Reflex t)
416462 type Client t m (QueryFlag sym :> sublayout) tag =
417463 Dynamic t Bool -> Client t m sublayout tag
418464
419− clientWithRoute Proxy q t req baseurl opts flag =
420− clientWithRoute (Proxy :: Proxy sublayout) q t req' baseurl opts
465+ clientWithRouteAndResultHandler Proxy q t req baseurl opts wrap flag =
466+ clientWithRouteAndResultHandler (Proxy :: Proxy sublayout) q t req' baseurl opts wrap
421467
422468 where req' = req { qParams = thisPair : qParams req }
423469 thisPair = (T.pack pName, QueryPartFlag flag) :: (Text, QueryPart t)
@@ -431,7 +477,7 @@ instance SupportsServantReflex t m => HasClient t m Raw tag where
431477 -> Event t tag
432478 -> m (Event t (ReqResult tag ()))
433479
434− clientWithRoute _ _ _ _ baseurl _ xhrs triggers = do
480+ clientWithRouteAndResultHandler _ _ _ _ baseurl _ wrap xhrs triggers = do
435481
436482 let xhrs' = liftA2 (\x path -> case x of
437483 Left e -> Left e
@@ -442,7 +488,7 @@ instance SupportsServantReflex t m => HasClient t m Raw tag where
442488 okReq = fmapMaybe (\(t,x) -> either (const Nothing) (Just . (t,)) x) xhrs'' :: Event t (tag, XhrRequest ())
443489
444490 resps <- performRequestsAsync okReq
445− return $ leftmost [ uncurry RequestFailure <$> badReq
491+ wrap $ leftmost [ uncurry RequestFailure <$> badReq
446492 , evalResponse (const $ Right ()) <$> resps
447493 ]
448494
@@ -467,73 +513,30 @@ instance SupportsServantReflex t m => HasClient t m Raw tag where
467513-- > where host = BaseUrl Http "localhost" 8080
468514-- > -- then you can just use "addBook" to query that endpoint
469515
470−instance (GHCJS'MimeRender ct a, IsXhrPayload (ToSend ct a), Show (ToSend ct a),
471− HasClient t m sublayout tag, Reflex t)
472− => HasClient t m (ReqBody (ct ': cts) (a :: Type) :> sublayout) tag where
516+instance (MimeRender ct a, HasClient t m sublayout tag, Reflex t)
517+ => HasClient t m (ReqBody (ct ': cts) a :> sublayout) tag where
473518
474519 type Client t m (ReqBody (ct ': cts) a :> sublayout) tag =
475− Dynamic t (Either Text (ToConvert ct a)) -> Client t m sublayout tag
520+ Dynamic t (Either Text a) -> Client t m sublayout tag
476521
477− clientWithRoute Proxy q t Req{..} baseurl opts body =
478− clientWithRoute (Proxy :: Proxy sublayout) q t req' baseurl opts
479− where req' = Req { reqBody = Just $ (fmap . fmap)
480− (\b -> (ghcjsMimeRender ctProxy atProxy b, ctString)) body
481− , ..}
522+ clientWithRouteAndResultHandler Proxy q t req baseurl opts wrap body =
523+ clientWithRouteAndResultHandler (Proxy :: Proxy sublayout) q t req' baseurl opts wrap
524+ where req' = req { reqBody = bodyBytesCT }
482525 ctProxy = Proxy :: Proxy ct
483− atProxy = Proxy :: Proxy a
484526 ctString = T.pack $ show $ contentType ctProxy
527+ bodyBytesCT = Just $ (fmap . fmap)
528+ (\b -> (mimeRender ctProxy b, ctString))
529+ body
485530
486−class Accept ctype => GHCJS'MimeRender (ctype :: Type) (a :: Type) where
487− type ToConvert ctype a :: Type
488− type ToConvert ctype a = a
489−
490− type ToSend ctype a :: Type
491− type ToSend ctype a = BS.ByteString
492531
493− ghcjsMimeRender
494− :: IsXhrPayload (ToSend ctype a)
495− => Proxy ctype -> Proxy a -> ToConvert ctype a -> ToSend ctype a
496− default ghcjsMimeRender
497− :: (IsXhrPayload (ToSend ctype a), MimeRender ctype a,
498− MimeRender ctype (ToConvert ctype a), ToSend ctype a ~ BS.ByteString)
499− => Proxy ctype -> Proxy a -> ToConvert ctype a -> ToSend ctype a
500− ghcjsMimeRender ctype _ = BL.toStrict . mimeRender ctype
501−
502−instance MimeRender JSON x => GHCJS'MimeRender JSON x
503−
504−instance MimeRender FormUrlEncoded x => GHCJS'MimeRender FormUrlEncoded x
505−
506−instance GHCJS'MimeRender OctetStream BL.ByteString where
507− type ToConvert OctetStream BL.ByteString = Blob
508− type ToSend OctetStream BL.ByteString = Blob
509− ghcjsMimeRender _ _ = id
510−
511−instance GHCJS'MimeRender PlainText String where
512− type ToSend PlainText String = Text
513− ghcjsMimeRender _ _ = T.pack
514−
515−instance GHCJS'MimeRender PlainText Text where
516− type ToSend PlainText Text = Text
517− ghcjsMimeRender _ _ = id
518−
519−instance GHCJS'MimeRender PlainText TL.Text where
520− type ToSend PlainText TL.Text = Text
521− ghcjsMimeRender _ _ = TL.toStrict
522−
523−instance GHCJS'MimeRender PlainText BL.ByteString where
524− type ToSend PlainText BL.ByteString = BS.ByteString
525− ghcjsMimeRender _ _ = BL.toStrict
526−
527−instance GHCJS'MimeRender PlainText BS.ByteString where
528− ghcjsMimeRender _ _ = id
529532
530533-- | Make the querying function append @path@ to the request path.
531534instance (KnownSymbol path, HasClient t m sublayout tag, Reflex t) => HasClient t m (path :> sublayout) tag where
532535 type Client t m (path :> sublayout) tag = Client t m sublayout tag
533536
534− clientWithRoute Proxy q t req baseurl opts =
535− clientWithRoute (Proxy :: Proxy sublayout) q t
536− (prependToPathParts (pure (Right $ T.pack p)) req) baseurl opts
537+ clientWithRouteAndResultHandler Proxy q t req baseurl opts wrap =
538+ clientWithRouteAndResultHandler (Proxy :: Proxy sublayout) q t
539+ (prependToPathParts (pure (Right $ T.pack p)) req) baseurl opts wrap
537540
538541 where p = symbolVal (Proxy :: Proxy path)
539542
@@ -541,23 +544,23 @@ instance (KnownSymbol path, HasClient t m sublayout tag, Reflex t) => HasClient
541544instance HasClient t m api tag => HasClient t m (Vault :> api) tag where
542545 type Client t m (Vault :> api) tag = Client t m api tag
543546
544− clientWithRoute Proxy q t req baseurl =
545− clientWithRoute (Proxy :: Proxy api) q t req baseurl
547+ clientWithRouteAndResultHandler Proxy =
548+ clientWithRouteAndResultHandler (Proxy :: Proxy api)
546549
547550
548551instance HasClient t m api tag => HasClient t m (RemoteHost :> api) tag where
549552 type Client t m (RemoteHost :> api) tag = Client t m api tag
550553
551− clientWithRoute Proxy q t req baseurl =
552− clientWithRoute (Proxy :: Proxy api) q t req baseurl
554+ clientWithRouteAndResultHandler Proxy =
555+ clientWithRouteAndResultHandler (Proxy :: Proxy api)
553556
554557
555558
556559instance HasClient t m api tag => HasClient t m (IsSecure :> api) tag where
557560 type Client t m (IsSecure :> api) tag = Client t m api tag
558561
559− clientWithRoute Proxy q t req baseurl =
560− clientWithRoute (Proxy :: Proxy api) q t req baseurl
562+ clientWithRouteAndResultHandler Proxy =
563+ clientWithRouteAndResultHandler (Proxy :: Proxy api)
561564
562565
563566instance (HasClient t m api tag, Reflex t)
@@ -566,8 +569,8 @@ instance (HasClient t m api tag, Reflex t)
566569 type Client t m (BasicAuth realm usr :> api) tag = Dynamic t (Maybe BasicAuthData)
567570 -> Client t m api tag
568571
569− clientWithRoute Proxy q t req baseurl opts authdata =
570− clientWithRoute (Proxy :: Proxy api) q t req' baseurl opts
572+ clientWithRouteAndResultHandler Proxy q t req baseurl opts wrap authdata =
573+ clientWithRouteAndResultHandler (Proxy :: Proxy api) q t req' baseurl opts wrap
571574 where
572575 req' = req { authData = Just authdata }
573576
@@ -610,7 +613,7 @@ for empty and one for non-empty lists).
610613instance (HasCookieAuth auths, HasClient t m api tag) => HasClient t m (Auth.Auth auths a :> api) tag where
611614
612615 type Client t m (Auth.Auth auths a :> api) tag = Client t m api tag
613− clientWithRoute Proxy = clientWithRoute (Proxy :: Proxy api)
616+ clientWithRouteAndResultHandler Proxy = clientWithRouteAndResultHandler (Proxy :: Proxy api)
614617
615618
616619type family HasCookieAuth xs :: Constraint where
@@ -619,3 +622,4 @@ type family HasCookieAuth xs :: Constraint where
619622 HasCookieAuth '[] = CookieAuthNotEnabled
620623
621624class CookieAuthNotEnabled
625+