Copyright | (c) 2015 Futurice |
---|---|
License | MIT (see the file LICENSE) |
Maintainer | Oleg Grenrus <oleg.grenrus@iki.fi> |
Stability | experimental |
Portability | GADTs and RankNTypes |
Safe Haskell | None |
Language | Haskell2010 |
Network.Waitra
is a very simple router.
It's useful for writing simple API web-services,
when you don't want to use the whole Yesod stack.
- type Path = String
- data Route where
- simpleRoute :: Method -> Path -> Application -> Route
- simpleGet :: Path -> Application -> Route
- simplePost :: Path -> Application -> Route
- simplePut :: Path -> Application -> Route
- simpleDelete :: Path -> Application -> Route
- routeGet :: RE Char a -> (a -> Application) -> Route
- routePost :: RE Char a -> (a -> Application) -> Route
- routePut :: RE Char a -> (a -> Application) -> Route
- routeDelete :: RE Char a -> (a -> Application) -> Route
- compile :: [Route] -> Middleware
- compileRoute :: Route -> Middleware
Types
We use strings, as - unluckily - Applicative
doesn't work with Text
directly.
Static paths routes
simpleRoute :: Method -> Path -> Application -> Route Source
simpleGet :: Path -> Application -> Route Source
simplePost :: Path -> Application -> Route Source
simplePut :: Path -> Application -> Route Source
simpleDelete :: Path -> Application -> Route Source
Regex paths routes
routeDelete :: RE Char a -> (a -> Application) -> Route Source
Compilation
compile :: [Route] -> Middleware Source
Turn the list of routes into Middleware
compileRoute :: Route -> Middleware Source