apiary-eventsource 1.1.0 → 1.2.0
raw patch · 2 files changed
+6/−34 lines, 2 filesdep −conduitdep −wai-eventsourcedep ~apiaryPVP ok
version bump matches the API change (PVP)
Dependencies removed: conduit, wai-eventsource
Dependency ranges changed: apiary
API changes (from Hackage documentation)
Files
- apiary-eventsource.cabal +3/−12
- src/Web/Apiary/EventSource.hs +3/−22
apiary-eventsource.cabal view
@@ -1,5 +1,5 @@ name: apiary-eventsource-version: 1.1.0+version: 1.2.0 synopsis: eventsource support for apiary web framework. description: example: <https://github.com/philopon/apiary/blob/master/examples/eventsource.hs>@@ -16,21 +16,12 @@ -- extra-source-files: cabal-version: >=1.10 -flag wai2apiary- default: False- manual: False- library exposed-modules: Web.Apiary.EventSource build-depends: base >=4.6 && <4.8- , apiary >=1.1 && <1.2+ , apiary >=1.1 && <1.3 , blaze-builder >=0.3 && <0.4- if flag(wai2apiary)- build-depends: wai-eventsource >=2.0 && <3.0- , conduit >=1.1 && <1.2- else- build-depends: wai-extra >=3.0 && <3.1-+ , wai-extra >=3.0 && <3.1 hs-source-dirs: src ghc-options: -O2 -Wall default-language: Haskell2010
src/Web/Apiary/EventSource.hs view
@@ -1,45 +1,26 @@-{-# LANGUAGE NoMonomorphismRestriction #-} {-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE CPP #-} module Web.Apiary.EventSource ( eventSourceIO, eventSourceChan , module Network.Wai.EventSource.EventStream ) where -import Web.Apiary+import Web.Apiary(MonadIO(..), status200) import Network.Wai.EventSource.EventStream (ServerEvent(..)) import qualified Network.Wai.EventSource.EventStream as E import Control.Concurrent.Chan (Chan, dupChan, readChan) import Control.Monad.Apiary.Action--import Data.Function+ (ActionT, status, contentType, stream, StreamingBody) -#ifdef VERSION_wai_eventsource-import Blaze.ByteString.Builder (Builder)-import Data.Conduit+import Data.Function(fix) -ioToSource :: IO ServerEvent -> Source IO (Flush Builder)-ioToSource a =- loop- where- loop = do- x <- liftIO a- case E.eventToBuilder x of- Nothing -> return ()- Just y -> do- yield $ Chunk y- yield Flush- loop-#else ioToSource :: IO ServerEvent -> StreamingBody ioToSource src send flush = fix $ \loop -> do se <- src case E.eventToBuilder se of Nothing -> return () Just b -> send b >> flush >> loop-#endif -- | eventsource with io action. since 0.11.3. eventSourceIO :: Monad m => IO ServerEvent -> ActionT exts prms m ()