Type safe URL generation and routing for Snap using web-routes, and builds on work
done by Jeremy Shaw.
Get started with the comprehensive tutorial.
Brief overview
It allows you to define a data type that represents the routes in your application:
data AppUrl
= Login -- routes to /login
| Logout -- routes to /logout
| User (Resource UserId) -- provides RESTful routes at /user
Resource
is documented in Snap.Snaplet.Router.REST, and makes defining RESTful routes easier. Also provided are functions to use the URL data type in your app:
someHandler :: Handler App App ()
someHandler :: doSomething >> redirectURL $ User Index
and to generate URLs in views:
linksHandler :: Handler App App ()
linksHandler = heistLocal (I.bindSplices linksSplices) $ render "links"
where
linksSplices = do
"loginUrl" ## urlSplice Login