How do I define a Server-Sent Event(SSE) end point for servant. The docs don't seem to cover this case.
If Servant is not designed for the realtime use case, which Haskell server framework supports SSE?
servant
uses WAI
, and you can always dip down into normal WAI
applications and all the libraries that exist for it with the Raw
combinator. So you can use Network.Wai.EventSource
from wai-extra
to create an Application
, which is the type of handlers for Raw
endpoints. Something like:
type MyApi = "normalapi" :> NormalApi
:<|> "sse" :> Raw
myServer :: Server MyAPI
myServer = normalServer :<|> eventSourceAppChan myChan