wai-routes 0.3.4 → 0.4.0
raw patch · 6 files changed
+27/−32 lines, 6 filesdep −conduitdep −path-piecesdep ~blaze-builderdep ~bytestringdep ~http-types
Dependencies removed: conduit, path-pieces
Dependency ranges changed: blaze-builder, bytestring, http-types, template-haskell, text, wai, yesod-routes
Files
- README.md +3/−1
- examples/Example.hs +2/−0
- src/Network/Wai/Middleware/Routes.hs +0/−1
- src/Network/Wai/Middleware/Routes/Handler.hs +6/−9
- src/Network/Wai/Middleware/Routes/Routes.hs +6/−9
- wai-routes.cabal +10/−12
README.md view
@@ -1,4 +1,4 @@-Wai Routes (wai-routes-0.3.4)+Wai Routes (wai-routes-0.4.0) ============================== [](https://travis-ci.org/ajnsit/wai-routes)@@ -80,4 +80,6 @@ * 0.3.2 : Added HandlerM Monad which makes it easier to build Handlers * 0.3.3 : Better exports from the Network.Wai.Middleware.Routes module * 0.3.4 : Added 'liftResourceT' to lift a ResourceT into HandlerM+* 0.4.0 : Wai 2 compatibility. Replaced 'liftResourceT' with 'lift'+
examples/Example.hs view
@@ -13,6 +13,7 @@ import Data.IORef import qualified Data.Map as M import Control.Monad.Trans+import Network.Wai.Middleware.RequestLogger -- The database of users data User = User@@ -144,6 +145,7 @@ application :: RouteM () application = do db <- liftIO $ newIORef initdb+ middleware logStdoutDev route (MyRoute db) route MySkippedRoute defaultAction $ staticApp $ defaultFileServerSettings "static"
src/Network/Wai/Middleware/Routes.hs view
@@ -51,7 +51,6 @@ -- * HandlerM Monad makes it easy to build a handler , HandlerM() , runHandlerM -- | Run a HandlerM to get a Handler- , liftResourceT -- | Lift a ResourceT into HandlerM , request -- | Access the request data , master -- | Access the master datatype , next -- | Run the next application in the stack
src/Network/Wai/Middleware/Routes/Handler.hs view
@@ -13,26 +13,23 @@ module Network.Wai.Middleware.Routes.Handler ( HandlerM() -- | A Monad that makes it easier to build a Handler , runHandlerM -- | Run a HandlerM to get a Handler- , liftResourceT -- | Lift a ResourceT into HandlerM , request -- | Access the request data , master -- | Access the master datatype , next -- | Run the next application in the stack ) where -import Data.Conduit (ResourceT) import Network.Wai (Request, Response)-import Control.Monad.Reader (ReaderT, ask, runReaderT, MonadReader, MonadIO, lift)+import Control.Monad.Reader (ReaderT, ask, runReaderT, MonadReader, MonadIO, lift, MonadTrans) import Network.Wai.Middleware.Routes.Routes (RequestData, Handler, waiReq, runNext) --- | The HandlerM Monad-newtype HandlerM master a = H { extractH :: ReaderT (HandlerState master) (ResourceT IO) a }- deriving (Monad, MonadIO, Functor, MonadReader (HandlerState master))+-- | The internal implementation of the HandlerM monad+newtype HandlerMI master m a = H { extractH :: ReaderT (HandlerState master) m a }+ deriving (Monad, MonadIO, Functor, MonadTrans, MonadReader (HandlerState master)) --- | Lift a ResourceT into HandlerM-liftResourceT :: ResourceT IO a -> HandlerM master a-liftResourceT = H . lift+-- | The HandlerM Monad+type HandlerM master a = HandlerMI master IO a -- | The state kept in a HandlerM Monad data HandlerState master = HandlerState
src/Network/Wai/Middleware/Routes/Routes.hs view
@@ -48,11 +48,8 @@ ) where --- Conduit-import Data.Conduit (ResourceT)- -- Wai-import Network.Wai (Middleware, Application, pathInfo, requestMethod, requestMethod, Response(ResponseBuilder), Request(..))+import Network.Wai (Middleware, Application, pathInfo, requestMethod, requestMethod, Response, Request(..), responseBuilder) import Network.HTTP.Types (decodePath, encodePath, queryTextToQuery, queryToQueryText, status405) -- Yesod Routes@@ -82,20 +79,20 @@ } -- | Run the next application in the stack-runNext :: RequestData -> ResourceT IO Response+runNext :: RequestData -> IO Response runNext req = nextApp req $ waiReq req -- | A `Handler` generates an App from the master datatype-type Handler master = master -> RequestData -> ResourceT IO Response+type Handler master = master -> RequestData -> IO Response -- Baked in applications that handle 404 and 405 errors -- TODO: Inspect the request to figure out acceptable output formats -- Currently we assume text/plain is acceptable app404 :: Handler master-app404 _master req = nextApp req $ waiReq req+app404 _master = runNext app405 :: Handler master-app405 _master _req = return $ ResponseBuilder status405 [contentType typePlain] $ fromByteString "405 - Method Not Allowed"+app405 _master _req = return $ responseBuilder status405 [contentType typePlain] $ fromByteString "405 - Method Not Allowed" -- | Generates all the things needed for efficient routing, -- including your application's `Route` datatype, and@@ -132,7 +129,7 @@ :: Handler master -> master -> Maybe (Route master)- -> RequestData -> ResourceT IO Response -- App+ -> RequestData -> IO Response -- App runHandler h master _ = h master -- | A `Routable` instance can be used in dispatching.
wai-routes.cabal view
@@ -1,5 +1,5 @@ Name: wai-routes-Version: 0.3.4+Version: 0.4.0 Synopsis: Typesafe URLs for Wai applications. Homepage: https://github.com/ajnsit/wai-routes License: MIT@@ -63,21 +63,19 @@ source-repository this type: git- location: http://github.com/ajnsit/wai-routes/tree/v0.3.4- tag: v0.3.4+ location: http://github.com/ajnsit/wai-routes/tree/v0.4.0+ tag: v0.4.0 Library hs-source-dirs: src Build-Depends: base >= 3 && < 5- , wai >= 1.3 && < 1.5- , conduit >= 0.5 && < 1.1- , path-pieces- , text- , bytestring- , http-types >= 0.7- , blaze-builder >= 0.2.1.4 && < 0.4- , template-haskell- , yesod-routes >= 1.2+ , wai >= 2 && < 2.1+ , text >= 0.11.3 && < 0.12+ , bytestring >= 0.10.0 && < 0.10.1+ , http-types >= 0.8.3 && < 0.8.4+ , blaze-builder >= 0.3.3 && < 0.3.4+ , template-haskell >= 2.8.0 && < 2.8.1+ , yesod-routes >= 1.2.0 && < 1.2.1 , mtl exposed-modules: Network.Wai.Middleware.Routes , Network.Wai.Middleware.Routes.Routes