| CARVIEW |
Select Language
HTTP/1.1 200 OK
Connection: keep-alive
Server: nginx/1.24.0 (Ubuntu)
Content-Type: text/html; charset=utf-8
Cache-Control: public, max-age=300
Content-Encoding: gzip
Via: 1.1 varnish, 1.1 varnish
Accept-Ranges: bytes
Age: 0
Date: Sat, 17 Jan 2026 03:01:16 GMT
X-Served-By: cache-dfw-kdal2120066-DFW, cache-bom-vanm7210097-BOM
X-Cache: MISS, MISS
X-Cache-Hits: 0, 0
X-Timer: S1768618876.472209,VS0,VE387
Vary: Accept, Accept-Encoding
transfer-encoding: chunked
wai-routing: Declarative routing for WAI.
[Skip to Readme]
wai-routing: Declarative routing for WAI.
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" (continue fetchUser) $
capture "name"
get "/user/find" (continue 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 -> Continue m -> m ResponseReceived
rmUser (name ::: foo) k = k $ ...
[Skip to Readme]
Modules
[Index]
Downloads
- wai-routing-0.13.0.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
| Versions [RSS] | 0.1, 0.2, 0.3, 0.3.1, 0.4, 0.4.1, 0.5, 0.5.1, 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), base (>=4.6 && <5.0), bytestring (>=0.10), bytestring-conversion (>=0.2), case-insensitive (>=1.1), cookie (>=0.4), http-types (>=0.8), transformers (>=0.3), wai (>=3.0), wai-predicates (>=0.8), wai-route (>=0.3) [details] |
| License | MPL-2.0 |
| Copyright | (C) 2014-2016 Toralf Wittner |
| Author | Toralf Wittner |
| Maintainer | Toralf Wittner <tw@dtex.org> |
| Uploaded | by ToralfWittner at 2016-08-01T22:25:14Z |
| Category | Web |
| Home page | https://gitlab.com/twittner/wai-routing/ |
| Bug tracker | https://gitlab.com/twittner/wai-routing/issues |
| Source repo | head: git clone git@gitlab.com:twittner/wai-routing.git |
| Distributions | |
| Reverse Dependencies | 1 direct, 0 indirect [details] |
| Downloads | 18779 total (112 in the last 30 days) |
| Rating | (no votes yet) [estimated by Bayesian average] |
| Your Rating |
|
| Status | Docs available [build log] Last success reported on 2016-08-01 [all 1 reports] |
Readme for wai-routing-0.13.0
[back to package description]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.