Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module provides data types useful for declaring RESTful routes.
Resource
is provided for the common case of resource specified
by a unique identifier (for e.g. /products/3
). SingletonResource
is provided for resources that do not require an identifier. Typical
usage would be as follows:
data AppUrl = User (Resource Int) | Profile SingletonResource | Login | Logout
This now allows you to define handlers for different end points for
your resource.
routeAppUrl appUrl =
case appUrl of
Login -> with auth handleLogin -- /login
Logout -> with auth handleLogout -- /logout
User Index -> handleUserIndex -- /user
User New -> handleUserNew -- /user/new
User (Show n) -> handleUserShow n -- /user/:Int
User (Edit n) -> handleUserEdit n -- /user/:Int/edit
Profile ShowS -> handleProfileShow -- /profile
Profile NewS -> handleProfileNew -- /profile/new
Profile EditS -> handleProfileEdit -- /profile/edit
Documentation
data PathInfo id => Resource id Source
A data type to represent RESTful resources that have a unique identifier.
The data type used as the identifier must be an instance of PathInfo
.
data SingletonResource Source
A data type to represent singleton RESTful resources. Generally these are identified in some other way, often the user's session.