nested-routes

Declarative, Compositional Url Handling for WAI


Keywords
library, web, Propose Tags, https://github.com/athanclark/nested-routes#readme, , Index, Quick Jump, Web.Routes.Nested, Web.Routes.Nested.Match, Web.Routes.Nested.Types, nested-routes-10.0.0.tar.gz, browse, Package description, Package maintainers, athanclark, edit package information , composable, haskell, haskell-warp, http-server
License
BSD-3-Clause
Install
cabal install nested-routes-10.0.0

Documentation

Logo

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