wai-routing 0.12.1 → 0.12.2
raw patch · 5 files changed
+21/−12 lines, 5 files
Files
- CHANGELOG.md +4/−0
- README.md +4/−0
- examples/eval-direct.hs +9/−7
- src/Network/Wai/Routing/Route.hs +1/−0
- wai-routing.cabal +3/−5
CHANGELOG.md view
@@ -1,3 +1,7 @@+0.12.2+-----------------------------------------------------------------------------+- Maintenance release.+ 0.12.1 ----------------------------------------------------------------------------- - Update `bytestring-conversion` upper bound.
README.md view
@@ -1,6 +1,10 @@+[][1]+ wai-routing enables the declaration of "routes" which handle requests to a specific URL. The set of possible handlers can be restricted by "predicates", which operate on WAI requests and have to be true or else the handler will not be called.++[1]: https://travis-ci.org/twittner/wai-routing
examples/eval-direct.hs view
@@ -8,12 +8,14 @@ -- -- The file "eval-routing.hs" does the same but using wai-routing. +{-# LANGUAGE OverloadedStrings #-}+ module Main (main) where import Control.Monad import Data.Attoparsec.ByteString.Char8 import Data.ByteString (ByteString)-import Data.ByteString.From+import Data.ByteString.Conversion import Data.String import Network.HTTP.Types import Network.Wai@@ -37,15 +39,15 @@ main = run 8080 $ logStdout start start :: Application-start r = case pathInfo r of+start r k = case pathInfo r of "eval":[] -> let x = join $ lookup "x" (queryString r) y = join $ lookup "y" (queryString r) f = join $ lookup "f" (queryString r)- in either (respond status400 . fromString)- (respond status200 . fromString . show)+ in either (k . respond status400 . fromString)+ (k . respond status200 . fromString . show) (eval f x y)- _ -> respond status404 ""+ _ -> k $ respond status404 "" eval :: Maybe ByteString -> Maybe ByteString -> Maybe ByteString -> Either String Int eval (Just f) (Just x) (Just y) = do@@ -59,5 +61,5 @@ Div -> return (x' `div` y') eval _ _ _ = Left "invalid arguments" -respond :: Monad m => Status -> Lazy.ByteString -> m Response-respond s = return . responseLBS s []+respond :: Status -> Lazy.ByteString -> Response+respond s = responseLBS s []
src/Network/Wai/Routing/Route.hs view
@@ -56,6 +56,7 @@ import Network.Wai.Predicate.Request import Network.Wai.Route.Tree (Tree) import Network.Wai.Routing.Request+import Prelude import qualified Data.ByteString.Char8 as C import qualified Data.ByteString.Lazy as Lazy
wai-routing.cabal view
@@ -1,11 +1,11 @@ name: wai-routing-version: 0.12.1+version: 0.12.2 synopsis: Declarative routing for WAI.-license: OtherLicense+license: MPL-2.0 license-file: LICENSE author: Toralf Wittner maintainer: Toralf Wittner <tw@dtex.org>-copyright: (c) 2014 Toralf Wittner+copyright: (C) 2014-2015 Toralf Wittner homepage: https://github.com/twittner/wai-routing/ bug-reports: https://github.com/twittner/wai-routing/issues stability: experimental@@ -67,7 +67,6 @@ default-language: Haskell2010 hs-source-dirs: src ghc-options: -Wall -O2 -fwarn-tabs -funbox-strict-fields- ghc-prof-options: -prof -auto-all exposed-modules: Network.Wai.Routing@@ -94,7 +93,6 @@ hs-source-dirs: test main-is: TestSuite.hs ghc-options: -Wall -O2 -fwarn-tabs- ghc-prof-options: -prof -auto-all other-modules: Tests.Wai.Route