packages feed

wai-extra 3.0.27 → 3.0.28

raw patch · 5 files changed

+36/−1 lines, 5 filesdep ~ansi-terminaldep ~fast-loggerdep ~wai-logger

Dependency ranges changed: ansi-terminal, fast-logger, wai-logger

Files

ChangeLog.md view
@@ -1,5 +1,9 @@ # Changelog for wai-extra +## 3.0.28++* Add `Network.Wai.EventSource.eventStreamAppRaw` [#767](https://github.com/yesodweb/wai/pull/767)+ ## 3.0.27  * Add custom request log formatter which includes response headers [#762](https://github.com/yesodweb/wai/pull/762)
Network/Wai/EventSource.hs view
@@ -5,6 +5,8 @@     headers:      > [ ("X-Accel-Buffering", "no"), ("Cache-Control", "no-cache")]++    There is a small example using these functions in the @example@ directory. -} module Network.Wai.EventSource (     ServerEvent(..),@@ -39,3 +41,18 @@             case eventToBuilder se of                 Nothing -> return ()                 Just b  -> sendChunk b >> flush >> loop++-- | Make a new WAI EventSource application with a handler that emits events.+--+-- @since 3.0.28+eventStreamAppRaw :: ((ServerEvent -> IO()) -> IO () -> IO ()) -> Application+eventStreamAppRaw handler _ sendResponse =+    sendResponse $ responseStream+        status200+        [(hContentType, "text/event-stream")]+        $ \sendChunk flush -> handler (sendEvent sendChunk) flush+    where+        sendEvent sendChunk event =+            case eventToBuilder event of+                Nothing -> return ()+                Just b  -> sendChunk b
Network/Wai/Middleware/Gzip.hs view
@@ -89,6 +89,9 @@ -- if gzip is supported. -- -- File responses will be compressed according to the 'GzipFiles' setting.+--+-- Will only be applied based on the 'gzipCheckMime' setting. For default+-- behavior, see 'defaultCheckMime'. gzip :: GzipSettings -> Middleware gzip set app env sendResponse = app env $ \res ->     case res of
example/Main.hs view
@@ -37,6 +37,17 @@                          Nothing                          [string8 . show $ time] +eventRaw :: (ServerEvent -> IO ()) -> IO () -> IO ()+eventRaw = handle 0+    where+        handle counter emit flush = do+            threadDelay 1000000+            emit $ ServerEvent (Just $ string8 "raw")+                               Nothing+                               [string8 . show $ counter]+            flush+            handle (counter + 1) emit flush+ main :: IO () main = do     chan <- newChan
wai-extra.cabal view
@@ -1,5 +1,5 @@ Name:                wai-extra-Version:             3.0.27+Version:             3.0.28 Synopsis:            Provides some basic WAI handlers and middleware. description:   Provides basic WAI handler and middleware functionality: