packages feed

simple 0.9.0.0 → 0.10.0.0

raw patch · 2 files changed

+16/−15 lines, 2 filesdep −conduitdep ~wai

Dependencies removed: conduit

Dependency ranges changed: wai

Files

simple.cabal view
@@ -1,5 +1,5 @@ name:                simple-version:             0.9.0.0+version:             0.10.0.0 synopsis: A minimalist web framework for the WAI server interface description: @@ -63,14 +63,13 @@     , aeson     , base64-bytestring     , bytestring-    , conduit     , directory     , filepath     , mime-types     , monad-control     , mtl     , simple-templates >= 0.7.0-    , wai >= 2.0+    , wai >= 3.0     , wai-extra     , http-types     , text
src/Web/Simple/Controller.hs view
@@ -41,8 +41,6 @@   , redirectBackOr   -- * Exception handling   , T.ControllerException-  -- * Integrating other WAI components-  , fromApp   -- * Low-level utilities   , body   , hoistEither@@ -50,11 +48,11 @@  import           Control.Monad.IO.Class import qualified Data.ByteString as S+import           Data.ByteString.Builder import qualified Data.ByteString.Char8 as S8 import qualified Data.ByteString.Lazy as L import qualified Data.ByteString.Lazy.Char8 as L8-import           Data.Conduit-import qualified Data.Conduit.List as CL+import           Data.Monoid import           Data.Text (Text) import           Network.HTTP.Types import           Network.Wai@@ -90,7 +88,9 @@  -- | Convert the controller into an 'Application' controllerApp :: s -> Controller s a -> Application-controllerApp = T.controllerApp+controllerApp s ctrl req responseFunc = do+  resp <- T.controllerApp s ctrl req+  responseFunc resp  -- | Provide a response --@@ -98,11 +98,6 @@ respond :: Response -> Controller s a respond = T.respond ---- | Lift an application to a controller-fromApp :: Application -> Controller s ()-fromApp = T.fromApp- -- | Matches on the hostname from the 'Request'. The route only succeeds on -- exact matches. routeHost :: S.ByteString -> Controller s a -> Controller s ()@@ -218,8 +213,15 @@ -- | Reads and returns the body of the HTTP request. body :: Controller s L8.ByteString body = do-  req <- request-  liftIO $ L8.fromChunks `fmap` (requestBody req $$ CL.consume)+  bodyProducer <- requestBody `fmap` request+  liftIO $ do+    result <- consume mempty bodyProducer+    return $ toLazyByteString result+  where consume bldr prod = do+          next <- prod+          if S.null next then+            return bldr+            else consume (mappend bldr (byteString next)) prod  -- | Returns the value of the given request header or 'Nothing' if it is not -- present in the HTTP request.