wai-routing: Declarative routing for WAI.
This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.
Warnings:
- 'ghc-options: -O2' is rarely needed. Check that it is giving a real benefit and not just imposing longer compile times on your users.
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.
Example:
import Data.ByteString (ByteString) import Data.Text (Text) import Network.Wai import Network.Wai.Predicate import Network.Wai.Routing import Network.Wai.Handler.Warp main :: IO () main = run 8080 (route (prepare start)) start :: Monad m => Routes a m () start = do get "/user/:name" fetchUser $ capture "name" get "/user/find" findUser $ query "byName" ||| query "byId" delete "/user/:name" rmUser $ capture "name" .&. opt (cookie "foo") fetchUser :: Monad m => Text -> m Response fetchUser name = ... findUser :: Monad m => Either ByteString Word64 -> m Response findUser (Left name) = ... findUser (Right ident) = ... rmUser :: Monad m => Text ::: Maybe Int -> m Response rmUser (name ::: foo) = ...
[Skip to Readme]
Properties
Versions | 0.1, 0.2, 0.3, 0.3.1, 0.4, 0.4.1, 0.5, 0.5.1, 0.5.2, 0.5.2, 0.5.3, 0.6, 0.7, 0.8, 0.9, 0.9.1, 0.10, 0.10.1, 0.10.2, 0.11, 0.11.1, 0.12, 0.12.1, 0.12.2, 0.12.3, 0.13.0 |
---|---|
Change log | CHANGELOG.md |
Dependencies | attoparsec (>=0.10 && <0.12), base (>=4 && <5), bytestring (>=0.9 && <0.11), bytestring-from (>=0.2 && <0.3), case-insensitive (>=1.1 && <1.3), cookie (>=0.4 && <0.5), http-types (>=0.8 && <0.9), transformers (>=0.3 && <0.4), wai (>=2.0 && <2.2), wai-predicates (>=0.3.1 && <0.4), wai-route (>=0.1 && <0.2) [details] |
License | LicenseRef-OtherLicense |
Copyright | (c) 2014 Toralf Wittner |
Author | Toralf Wittner |
Maintainer | Toralf Wittner <tw@dtex.org> |
Category | Web |
Source repo | head: git clone git://github.com/twittner/wai-routing.git |
Uploaded | by ToralfWittner at 2014-04-01T20:42:11Z |
Modules
- Network
- Wai
- Network.Wai.Routing
- Network.Wai.Routing.Predicate
- Network.Wai.Routing.Request
- Network.Wai.Routing.Route
- Network.Wai.Routing
- Wai
Downloads
- wai-routing-0.5.2.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
Package maintainers
For package maintainers and hackage trustees