packages feed

warped 0.0.2 → 0.0.3

raw patch · 2 files changed

+15/−4 lines, 2 filesdep +aeson

Dependencies added: aeson

Files

src/Network/Warped/Application.hs view
@@ -18,12 +18,14 @@   , answer   , answerStatus   , answerSource+  , answerJson   , withHeader   ) where  import Blaze.ByteString.Builder import Control.Concurrent.Async.Lifted import Control.Monad.Trans.Control+import Data.Aeson import Data.Conduit import Data.UUID                       hiding (fromByteString) import Network.HTTP.Types@@ -107,7 +109,7 @@ answerStatus :: MonadWai c m => Status -> ResponseHeaders -> m ResponseReceived answerStatus status headers = do   sessionUid <- view wcSessionUid-  let headers' = (hSessionUid, toASCIIBytes sessionUid) : headers+  let headers' = hSessionUid =. toASCIIBytes sessionUid : headers   answer $ responseLBS status headers' mempty  -- | Stream response.@@ -115,8 +117,16 @@ answerSource :: MonadWai c m => Status -> ResponseHeaders -> Source IO (Flush Builder) -> m ResponseReceived answerSource status headers response = do   sessionUid <- view wcSessionUid-  let headers' = (hSessionUid, toASCIIBytes sessionUid) : headers+  let headers' = hSessionUid =. toASCIIBytes sessionUid : headers   answer $ responseSource status headers' response++-- | JSON response.+--+answerJson :: (MonadWai c m, ToJSON a) => Status -> ResponseHeaders -> a -> m ResponseReceived+answerJson status headers value = do+  sessionUid <- view wcSessionUid+  let headers' = hSessionUid =. toASCIIBytes sessionUid : headers+  answer $ responseLBS status headers' $ encode value  -- | Lookup header. --
warped.cabal view
@@ -1,5 +1,5 @@ name:                  warped-version:               0.0.2+version:               0.0.3 synopsis:              Warp and Wai Library. description:           Library support around WAI and warp server. homepage:              https://github.com/swift-nav/warped@@ -27,7 +27,8 @@                      , Network.Warped.Types.Ctx   ghc-options:         -Wall   default-language:    Haskell2010-  build-depends:       base >= 4.9 && < 5+  build-depends:       aeson+                     , base >= 4.9 && < 5                      , blaze-builder                      , conduit                      , http-types