Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 19 days 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 9 years ago)
- Default Branch: master
- Last Pushed: 2023-09-28T09:49:35.000Z (about 1 year ago)
- Last Synced: 2024-04-26T01:20:37.530Z (7 months ago)
- Topics: composable, haskell, haskell-warp, http-server
- Language: Haskell
- Homepage:
- Size: 322 KB
- Stars: 10
- Watchers: 4
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![Logo](https://raw.githubusercontent.com/athanclark/nested-routes/269e8dd2105e9fea314b4374e19ecacca6f50659/logo.svg)
```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
```