@@ -71,7 +71,7 @@ import Servant.API.Generic
71
71
(GenericMode (.. ), ToServant , ToServantApi
72
72
, GenericServant , toServant , fromServant )
73
73
import Servant.API.ContentTypes
74
- (contentTypes , AllMime (allMime ), AllMimeUnrender (allMimeUnrender ))
74
+ (contentTypes , AllMime (allMime ), AllMimeUnrender (allMimeUnrender ), EventStream )
75
75
import Servant.API.QueryString (ToDeepQuery (.. ), generateDeepParam )
76
76
import Servant.API.Status
77
77
(statusFromNat )
@@ -81,6 +81,10 @@ import Servant.API.Modifiers
81
81
import Servant.API.TypeErrors
82
82
import Servant.API.UVerb
83
83
(HasStatus , HasStatuses (Statuses , statuses ), UVerb , Union , Unique , inject , statusOf , foldMapUnion , matchUnion )
84
+ import Servant.API.ServerSentEvents
85
+ (EventKind (JsonEvent , RawEvent ), ServerSentEvents' )
86
+ import Servant.API.Stream
87
+ (NoFraming )
84
88
85
89
import Servant.Client.Core.Auth
86
90
import Servant.Client.Core.BasicAuth
@@ -90,6 +94,7 @@ import Servant.Client.Core.Response
90
94
import Servant.Client.Core.MultiVerb.ResponseUnrender
91
95
import qualified Servant.Client.Core.Response as Response
92
96
import Servant.Client.Core.RunClient
97
+ import Servant.Client.Core.ServerSentEvents
93
98
import Servant.API.MultiVerb
94
99
import qualified Network.HTTP.Media as M
95
100
import Data.Typeable
@@ -451,6 +456,63 @@ instance {-# OVERLAPPING #-}
451
456
, requestMethod = reflectMethod (Proxy :: Proxy method )
452
457
}
453
458
459
+ type SseClientDelegate method status =
460
+ Stream method status NoFraming EventStream
461
+
462
+ instance
463
+ ( RunClient m
464
+ , HasClient m (SseClientDelegate method status (EventMessageStreamT IO ))
465
+ )
466
+ => HasClient m (ServerSentEvents' method status 'RawEvent EventMessage ) where
467
+ type Client m (ServerSentEvents' method status 'RawEvent EventMessage ) =
468
+ Client m (SseClientDelegate method status (EventMessageStreamT IO ))
469
+
470
+ hoistClientMonad p _ =
471
+ hoistClientMonad
472
+ p
473
+ (Proxy :: Proxy (SseClientDelegate method status (EventMessageStreamT IO )))
474
+
475
+ clientWithRoute p _ =
476
+ clientWithRoute
477
+ p
478
+ (Proxy :: Proxy (SseClientDelegate method status (EventMessageStreamT IO )))
479
+
480
+ instance
481
+ ( RunClient m
482
+ , HasClient m (SseClientDelegate method status (EventStreamT IO ))
483
+ )
484
+ => HasClient m (ServerSentEvents' method status 'RawEvent (Event a )) where
485
+ type Client m (ServerSentEvents' method status 'RawEvent (Event a )) =
486
+ Client m (SseClientDelegate method status (EventStreamT IO ))
487
+
488
+ hoistClientMonad p _ =
489
+ hoistClientMonad
490
+ p
491
+ (Proxy :: Proxy (SseClientDelegate method status (EventStreamT IO )))
492
+
493
+ clientWithRoute p _ =
494
+ clientWithRoute
495
+ p
496
+ (Proxy :: Proxy (SseClientDelegate method status (EventStreamT IO )))
497
+
498
+ instance
499
+ ( RunClient m
500
+ , HasClient m (SseClientDelegate method status (JsonEventStreamT IO a ))
501
+ )
502
+ => HasClient m (ServerSentEvents' method status 'JsonEvent a ) where
503
+ type Client m (ServerSentEvents' method status 'JsonEvent a ) =
504
+ Client m (SseClientDelegate method status (JsonEventStreamT IO a ))
505
+
506
+ hoistClientMonad p _ =
507
+ hoistClientMonad
508
+ p
509
+ (Proxy :: Proxy (SseClientDelegate method status (JsonEventStreamT IO a )))
510
+
511
+ clientWithRoute p _ =
512
+ clientWithRoute
513
+ p
514
+ (Proxy :: Proxy (SseClientDelegate method status (JsonEventStreamT IO a )))
515
+
454
516
-- | If you use a 'Header' in one of your endpoints in your API,
455
517
-- the corresponding querying function will automatically take
456
518
-- an additional argument of the type specified by your 'Header',
0 commit comments