@@ -1,18 +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 #-}
11−{-# LANGUAGE LambdaCase #-}
128{-# LANGUAGE MultiParamTypeClasses #-}
139{-# LANGUAGE OverloadedStrings #-}
1410{-# LANGUAGE PolyKinds #-}
15−{-# LANGUAGE RecordWildCards #-}
11+{-# LANGUAGE Rank2Types #-}
1612{-# LANGUAGE ScopedTypeVariables #-}
1713{-# LANGUAGE TupleSections #-}
1814{-# LANGUAGE TypeFamilies #-}
@@ -30,9 +26,10 @@
3026module Servant.Reflex
3127 ( client
3228 , clientWithOpts
29+ , clientWithOptsAndResultHandler
3330 , clientWithRoute
31+ , clientWithRouteAndResultHandler
3432 , BuildHeaderKeysTo(..)
35− , GHCJS'MimeRender(..)
3633 , toHeaders
3734 , HasClient
3835 , Client
@@ -42,56 +39,56 @@ module Servant.Reflex
4239
4340------------------------------------------------------------------------------
4441import Control.Applicative
45−import qualified Data.ByteString as BS
46−import qualified Data.ByteString.Lazy as BL
47−import Data.CaseInsensitive (mk)
42+import qualified Data.CaseInsensitive as CI
4843import Data.Functor.Identity
49−import Data.Kind (Type)
50−import qualified Data.Map as Map
51−import Data.Monoid ((<>))
52−import Data.Proxy (Proxy (..))
53−import qualified Data.Set as Set
54−import Data.Text (Text)
55−import qualified Data.Text as T
56−import qualified Data.Text.Encoding as E
57−import qualified Data.Text.Lazy as TL
58−import GHC.Exts (Constraint)
59−import GHC.TypeLits (KnownSymbol, symbolVal)
60−import GHCJS.DOM.Types (Blob)
61−import Servant.API ((:<|>) (..), (:>), Accept (..),
62− BasicAuth, BasicAuthData,
63− BuildHeadersTo (..), Capture,
64− FormUrlEncoded, Header, Headers (..),
65− HttpVersion, IsSecure, JSON,
66− MimeRender (..), NoContent,
67− OctetStream, PlainText, QueryFlag,
68− QueryParam, QueryParams, Raw,
69− ReflectMethod (..), RemoteHost,
70− ReqBody, ToHttpApiData (..), Vault,
71− Verb, contentType)
72−import qualified Servant.Auth as Auth
73−
74−import Reflex.Dom.Core (Dynamic, Event, IsXhrPayload, Reflex,
75− XhrRequest (..), XhrResponse (..),
76− XhrResponseHeaders (..),
77− attachPromptlyDynWith, constDyn, ffor,
78− fmapMaybe, leftmost,
79− 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)
8072------------------------------------------------------------------------------
81−import Servant.Common.BaseUrl (BaseUrl (..), Scheme (..),
82− SupportsServantReflex, baseUrlWidget,
83− showBaseUrl)
84−import Servant.Common.Req (ClientOptions (..), MimeUnrender (..),
85− QParam (..), QueryPart (..), Req (..),
86− ReqResult (..), addHeader, authData,
87− defReq, defaultClientOptions,
88− evalResponse, performRequestsCT,
89− performRequestsNoBody,
90− performSomeRequestsAsync,
91− prependToPathParts, qParamToQueryPart,
92− qParams, reqBody, reqFailure,
93− reqMethod, reqSuccess, reqTag,
94− 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)
9592
9693
9794-- * Accessing APIs as a Client
@@ -106,7 +103,7 @@ import Servant.Common.Req (ClientOptions (..), MimeUnrender (..),
106103-- >
107104-- > getAllBooks :: Event t l -> m (Event t (l, ReqResult [Book]))
108105-- > postNewBook :: Dynamic t (Maybe Book) -> Event t l
109−-- -> m (Event t (l, ReqResult Book)))
106+-- > -> m (Event t (l, ReqResult Book)))
110107-- > (getAllBooks :<|> postNewBook) = client myApi host
111108-- > where host = constDyn $ BaseUrl Http "localhost" 8080
112109client
@@ -128,21 +125,53 @@ clientWithOpts
128125 -> Client t m layout tag
129126clientWithOpts p q t baseurl = clientWithRoute p q t defReq baseurl
130127
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+
131142
132143-- | This class lets us define how each API combinator
133144-- influences the creation of an HTTP request. It's mostly
134145-- an internal class, you can just use 'client'.
135−class HasClient t m layout (tag :: Type) where
136− type Client t m layout tag :: Type
137− 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
138167
139168
140169instance (HasClient t m a tag, HasClient t m b tag) => HasClient t m (a :<|> b) tag where
141170 type Client t m (a :<|> b) tag = Client t m a tag :<|> Client t m b tag
142171
143− clientWithRoute Proxy q pTag req baseurl opts =
144− clientWithRoute (Proxy :: Proxy a) q pTag req baseurl opts :<|>
145− 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
146175
147176
148177-- Capture. Example:
@@ -163,11 +192,9 @@ instance (SupportsServantReflex t m, ToHttpApiData a, HasClient t m sublayout ta
163192 type Client t m (Capture capture a :> sublayout) tag =
164193 Dynamic t (Either Text a) -> Client t m sublayout tag
165194
166− clientWithRoute Proxy q t req baseurl opts val =
167− clientWithRoute (Proxy :: Proxy sublayout)
168− q t
169− (prependToPathParts p req)
170− 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
171198 where p = (fmap . fmap) (toUrlPiece) val
172199
173200
@@ -180,8 +207,8 @@ instance {-# OVERLAPPABLE #-}
180207 Event t tag -> m (Event t (ReqResult tag a))
181208 -- TODO how to access input types here?
182209 -- ExceptT ServantError IO a
183− clientWithRoute Proxy _ _ req baseurl opts trigs =
184− 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
185212 where method = E.decodeUtf8 $ reflectMethod (Proxy :: Proxy method)
186213 req' = req { reqMethod = method }
187214
@@ -194,29 +221,33 @@ instance {-# OVERLAPPING #-}
194221 Event t tag -> m (Event t (ReqResult tag NoContent))
195222 -- TODO: how to access input types here?
196223 -- ExceptT ServantError IO NoContent
197− clientWithRoute Proxy _ _ req baseurl opts =
198− (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
199226 where method = E.decodeUtf8 $ reflectMethod (Proxy :: Proxy method)
200227
201228
202229toHeaders :: BuildHeadersTo ls => ReqResult tag a -> ReqResult tag (Headers ls a)
203230toHeaders r =
204− let toBS = E.encodeUtf8
205− hdrs = maybe []
206− (\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))
207233 (Map.toList $ _xhrResponse_headers xhr))
208234 (response r)
209235 in ffor r $ \a -> Headers {getResponse = a ,getHeadersHList = buildHeadersTo hdrs}
210236
237+
211238class BuildHeaderKeysTo hs where
212− buildHeaderKeysTo :: Proxy hs -> [T.Text]
239+ buildHeaderKeysTo :: Proxy hs -> [CI.CI T.Text]
213240
214241instance {-# OVERLAPPABLE #-} BuildHeaderKeysTo '[]
215242 where buildHeaderKeysTo _ = []
216243
217244instance {-# OVERLAPPABLE #-} (BuildHeaderKeysTo xs, KnownSymbol h)
218245 => BuildHeaderKeysTo ((Header h v) ': xs) where
219− 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+
220251
221252-- HEADERS Verb (Content) --
222253-- Headers combinator not treated in fully general case,
@@ -231,10 +262,10 @@ instance {-# OVERLAPPABLE #-}
231262 ) => HasClient t m (Verb method status cts' (Headers ls a)) tag where
232263 type Client t m (Verb method status cts' (Headers ls a)) tag =
233264 Event t tag -> m (Event t (ReqResult tag (Headers ls a)))
234− clientWithRoute Proxy _ _ req baseurl opts trigs = do
265+ clientWithRouteAndResultHandler Proxy _ _ req baseurl opts wrap trigs = do
235266 let method = E.decodeUtf8 $ reflectMethod (Proxy :: Proxy method)
236267 resp <- fmap runIdentity <$> performRequestsCT (Proxy :: Proxy ct) method (constDyn $ Identity req') baseurl opts trigs
237− return $ toHeaders <$> resp
268+ wrap $ toHeaders <$> resp
238269 where req' = req { respHeaders =
239270 OnlyHeaders (Set.fromList (buildHeaderKeysTo (Proxy :: Proxy ls)))
240271 }
@@ -247,10 +278,10 @@ instance {-# OVERLAPPABLE #-}
247278 ) => HasClient t m (Verb method status cts (Headers ls NoContent)) tag where
248279 type Client t m (Verb method status cts (Headers ls NoContent)) tag
249280 = Event t tag -> m (Event t (ReqResult tag (Headers ls NoContent)))
250− clientWithRoute Proxy _ _ req baseurl opts trigs = do
281+ clientWithRouteAndResultHandler Proxy _ _ req baseurl opts wrap trigs = do
251282 let method = E.decodeUtf8 $ reflectMethod (Proxy :: Proxy method)
252283 resp <- fmap runIdentity <$> performRequestsNoBody method (constDyn $ Identity req') baseurl opts trigs
253− return $ toHeaders <$> resp
284+ wrap $ toHeaders <$> resp
254285 where req' = req {respHeaders =
255286 OnlyHeaders (Set.fromList (buildHeaderKeysTo (Proxy :: Proxy ls)))
256287 }
@@ -277,11 +308,11 @@ instance (KnownSymbol sym, ToHttpApiData a,
277308 type Client t m (Header sym a :> sublayout) tag =
278309 Dynamic t (Either Text a) -> Client t m sublayout tag
279310
280− clientWithRoute Proxy q t req baseurl opts eVal =
281− clientWithRoute (Proxy :: Proxy sublayout)
282− q t
283− (Servant.Common.Req.addHeader hname eVal req)
284− 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
285316 where hname = T.pack $ symbolVal (Proxy :: Proxy sym)
286317
287318
@@ -295,8 +326,21 @@ instance HasClient t m sublayout tag
295326 type Client t m (HttpVersion :> sublayout) tag =
296327 Client t m sublayout tag
297328
298− clientWithRoute Proxy q t =
299− 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+
300344
301345
302346-- | If you use a 'QueryParam' in one of your endpoints in your API,
@@ -332,9 +376,9 @@ instance (KnownSymbol sym, ToHttpApiData a, HasClient t m sublayout tag, Reflex
332376 Dynamic t (QParam a) -> Client t m sublayout tag
333377
334378 -- if mparam = Nothing, we don't add it to the query string
335− clientWithRoute Proxy q t req baseurl opts mparam =
336− clientWithRoute (Proxy :: Proxy sublayout) q t
337− (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
338382
339383 where pname = symbolVal (Proxy :: Proxy sym)
340384 --p prm = QueryPartParam $ (fmap . fmap) (toQueryParam) prm
@@ -378,8 +422,8 @@ instance (KnownSymbol sym, ToHttpApiData a, HasClient t m sublayout tag, Reflex
378422 type Client t m (QueryParams sym a :> sublayout) tag =
379423 Dynamic t [a] -> Client t m sublayout tag
380424
381− clientWithRoute Proxy q t req baseurl opts paramlist =
382− 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
383427
384428 where req' = req { qParams = (T.pack pname, params') : qParams req }
385429 pname = symbolVal (Proxy :: Proxy sym)
@@ -418,8 +462,8 @@ instance (KnownSymbol sym, HasClient t m sublayout tag, Reflex t)
418462 type Client t m (QueryFlag sym :> sublayout) tag =
419463 Dynamic t Bool -> Client t m sublayout tag
420464
421− clientWithRoute Proxy q t req baseurl opts flag =
422− 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
423467
424468 where req' = req { qParams = thisPair : qParams req }
425469 thisPair = (T.pack pName, QueryPartFlag flag) :: (Text, QueryPart t)
@@ -433,7 +477,7 @@ instance SupportsServantReflex t m => HasClient t m Raw tag where
433477 -> Event t tag
434478 -> m (Event t (ReqResult tag ()))
435479
436− clientWithRoute _ _ _ _ baseurl _ xhrs triggers = do
480+ clientWithRouteAndResultHandler _ _ _ _ baseurl _ wrap xhrs triggers = do
437481
438482 let xhrs' = liftA2 (\x path -> case x of
439483 Left e -> Left e
@@ -444,7 +488,7 @@ instance SupportsServantReflex t m => HasClient t m Raw tag where
444488 okReq = fmapMaybe (\(t,x) -> either (const Nothing) (Just . (t,)) x) xhrs'' :: Event t (tag, XhrRequest ())
445489
446490 resps <- performRequestsAsync okReq
447− return $ leftmost [ uncurry RequestFailure <$> badReq
491+ wrap $ leftmost [ uncurry RequestFailure <$> badReq
448492 , evalResponse (const $ Right ()) <$> resps
449493 ]
450494
@@ -469,73 +513,30 @@ instance SupportsServantReflex t m => HasClient t m Raw tag where
469513-- > where host = BaseUrl Http "localhost" 8080
470514-- > -- then you can just use "addBook" to query that endpoint
471515
472−instance (GHCJS'MimeRender ct a, IsXhrPayload (ToSend ct a), Show (ToSend ct a),
473− HasClient t m sublayout tag, Reflex t)
474− => 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
475518
476519 type Client t m (ReqBody (ct ': cts) a :> sublayout) tag =
477− Dynamic t (Either Text (ToConvert ct a)) -> Client t m sublayout tag
520+ Dynamic t (Either Text a) -> Client t m sublayout tag
478521
479− clientWithRoute Proxy q t Req{..} baseurl opts body =
480− clientWithRoute (Proxy :: Proxy sublayout) q t req' baseurl opts
481− where req' = Req { reqBody = Just $ (fmap . fmap)
482− (\b -> (ghcjsMimeRender ctProxy atProxy b, ctString)) body
483− , ..}
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 }
484525 ctProxy = Proxy :: Proxy ct
485− atProxy = Proxy :: Proxy a
486526 ctString = T.pack $ show $ contentType ctProxy
527+ bodyBytesCT = Just $ (fmap . fmap)
528+ (\b -> (mimeRender ctProxy b, ctString))
529+ body
487530
488−class Accept ctype => GHCJS'MimeRender (ctype :: Type) (a :: Type) where
489− type ToConvert ctype a :: Type
490− type ToConvert ctype a = a
491−
492− type ToSend ctype a :: Type
493− type ToSend ctype a = BS.ByteString
494531
495− ghcjsMimeRender
496− :: IsXhrPayload (ToSend ctype a)
497− => Proxy ctype -> Proxy a -> ToConvert ctype a -> ToSend ctype a
498− default ghcjsMimeRender
499− :: (MimeRender ctype a,
500− MimeRender ctype (ToConvert ctype a), ToSend ctype a ~ BS.ByteString)
501− => Proxy ctype -> Proxy a -> ToConvert ctype a -> ToSend ctype a
502− ghcjsMimeRender ctype _ = BL.toStrict . mimeRender ctype
503−
504−instance MimeRender JSON x => GHCJS'MimeRender JSON x
505−
506−instance MimeRender FormUrlEncoded x => GHCJS'MimeRender FormUrlEncoded x
507−
508−instance GHCJS'MimeRender OctetStream BL.ByteString where
509− type ToConvert OctetStream BL.ByteString = Either BL.ByteString Blob
510− type ToSend OctetStream BL.ByteString = Either BS.ByteString Blob
511− ghcjsMimeRender _ _ = \case Left bl -> Left $ BL.toStrict bl; Right x -> Right x
512−
513−instance GHCJS'MimeRender PlainText String where
514− type ToSend PlainText String = Text
515− ghcjsMimeRender _ _ = T.pack
516−
517−instance GHCJS'MimeRender PlainText Text where
518− type ToSend PlainText Text = Text
519− ghcjsMimeRender _ _ = id
520−
521−instance GHCJS'MimeRender PlainText TL.Text where
522− type ToSend PlainText TL.Text = Text
523− ghcjsMimeRender _ _ = TL.toStrict
524−
525−instance GHCJS'MimeRender PlainText BL.ByteString where
526− type ToSend PlainText BL.ByteString = BS.ByteString
527− ghcjsMimeRender _ _ = BL.toStrict
528−
529−instance GHCJS'MimeRender PlainText BS.ByteString where
530− ghcjsMimeRender _ _ = id
531532
532533-- | Make the querying function append @path@ to the request path.
533534instance (KnownSymbol path, HasClient t m sublayout tag, Reflex t) => HasClient t m (path :> sublayout) tag where
534535 type Client t m (path :> sublayout) tag = Client t m sublayout tag
535536
536− clientWithRoute Proxy q t req baseurl opts =
537− clientWithRoute (Proxy :: Proxy sublayout) q t
538− (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
539540
540541 where p = symbolVal (Proxy :: Proxy path)
541542
@@ -543,23 +544,23 @@ instance (KnownSymbol path, HasClient t m sublayout tag, Reflex t) => HasClient
543544instance HasClient t m api tag => HasClient t m (Vault :> api) tag where
544545 type Client t m (Vault :> api) tag = Client t m api tag
545546
546− clientWithRoute Proxy q t req baseurl =
547− clientWithRoute (Proxy :: Proxy api) q t req baseurl
547+ clientWithRouteAndResultHandler Proxy =
548+ clientWithRouteAndResultHandler (Proxy :: Proxy api)
548549
549550
550551instance HasClient t m api tag => HasClient t m (RemoteHost :> api) tag where
551552 type Client t m (RemoteHost :> api) tag = Client t m api tag
552553
553− clientWithRoute Proxy q t req baseurl =
554− clientWithRoute (Proxy :: Proxy api) q t req baseurl
554+ clientWithRouteAndResultHandler Proxy =
555+ clientWithRouteAndResultHandler (Proxy :: Proxy api)
555556
556557
557558
558559instance HasClient t m api tag => HasClient t m (IsSecure :> api) tag where
559560 type Client t m (IsSecure :> api) tag = Client t m api tag
560561
561− clientWithRoute Proxy q t req baseurl =
562− clientWithRoute (Proxy :: Proxy api) q t req baseurl
562+ clientWithRouteAndResultHandler Proxy =
563+ clientWithRouteAndResultHandler (Proxy :: Proxy api)
563564
564565
565566instance (HasClient t m api tag, Reflex t)
@@ -568,8 +569,8 @@ instance (HasClient t m api tag, Reflex t)
568569 type Client t m (BasicAuth realm usr :> api) tag = Dynamic t (Maybe BasicAuthData)
569570 -> Client t m api tag
570571
571− clientWithRoute Proxy q t req baseurl opts authdata =
572− 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
573574 where
574575 req' = req { authData = Just authdata }
575576
@@ -612,7 +613,7 @@ for empty and one for non-empty lists).
612613instance (HasCookieAuth auths, HasClient t m api tag) => HasClient t m (Auth.Auth auths a :> api) tag where
613614
614615 type Client t m (Auth.Auth auths a :> api) tag = Client t m api tag
615− clientWithRoute Proxy = clientWithRoute (Proxy :: Proxy api)
616+ clientWithRouteAndResultHandler Proxy = clientWithRouteAndResultHandler (Proxy :: Proxy api)
616617
617618
618619type family HasCookieAuth xs :: Constraint where
@@ -621,3 +622,4 @@ type family HasCookieAuth xs :: Constraint where
621622 HasCookieAuth '[] = CookieAuthNotEnabled
622623
623624class CookieAuthNotEnabled
625+