https://github.com/athanclark/nested-routes
Declarative, Compositional Url Handling for WAI
https://github.com/athanclark/nested-routes
composable haskell haskell-warp http-server
Last synced: 2 months ago
JSON representation
Declarative, Compositional Url Handling for WAI
- Host: GitHub
- URL: https://github.com/athanclark/nested-routes
- Owner: athanclark
- License: bsd-3-clause
- Created: 2015-03-29T20:24:11.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2023-09-28T09:49:35.000Z (almost 2 years ago)
- Last Synced: 2025-04-22T22:13:44.271Z (2 months ago)
- Topics: composable, haskell, haskell-warp, http-server
- Language: Haskell
- Homepage:
- Size: 322 KB
- Stars: 10
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

```haskell
routes :: RouterT (MiddlewareT m) sec m ()
routes = do
matchHere $ action $ do
get $ do
json ("some cool json", True, 12) -- application/json
text "Yo" -- text/plain
matchGroup (l_ "someChunk" > o_) $ do
match (p_ "some parser" Attoparsec.doube > o_) $ \(d :: Double) -> -- "/someChunk/124.234" would match
action $ ...
matchGroup (r_ [regex|/^(\.)+(.*)/|] > o_) $ \(matches :: [String]) -> -- "/someChunk/....huh?" would match
action $ ...myMiddleware :: MiddlewareT m
myMiddleware = route routes
```