@@ -5,6 +5,8 @@
55 headers:
66
77 > [ ("X-Accel-Buffering", "no"), ("Cache-Control", "no-cache")]
8+
9+ There is a small example using these functions in the @example@ directory.
810-}
911module Network.Wai.EventSource (
1012 ServerEvent(..),
@@ -39,3 +41,18 @@ eventSourceAppIO src _ sendResponse =
3941 case eventToBuilder se of
4042 Nothing -> return ()
4143 Just b -> sendChunk b >> flush >> loop
44+
45+-- | Make a new WAI EventSource application with a handler that emits events.
46+--
47+-- @since 3.0.28
48+eventStreamAppRaw :: ((ServerEvent -> IO()) -> IO () -> IO ()) -> Application
49+eventStreamAppRaw handler _ sendResponse =
50+ sendResponse $ responseStream
51+ status200
52+ [(hContentType, "text/event-stream")]
53+ $ \sendChunk flush -> handler (sendEvent sendChunk) flush
54+ where
55+ sendEvent sendChunk event =
56+ case eventToBuilder event of
57+ Nothing -> return ()
58+ Just b -> sendChunk b