| Safe Haskell | Safe |
|---|
Data.IterIO.Http.Support.RestController
Description
This module defines the RestController class
- class Monad m => RestController t b m a where
- restIndex :: a -> Action t b m ()
- restShow :: a -> ByteString -> Action t b m ()
- restNew :: a -> Action t b m ()
- restCreate :: a -> Action t b m ()
- restEdit :: a -> ByteString -> Action t b m ()
- restUpdate :: a -> ByteString -> Action t b m ()
- restDestroy :: a -> ByteString -> Action t b m ()
- routeRestController :: RestController t b m a => String -> a -> ActionRoute b m t
Documentation
class Monad m => RestController t b m a whereSource
The class RestController allows a set of actions to be routed using
RESTful HTTP verbs.
Methods
restIndex :: a -> Action t b m ()Source
GET /
restShow :: a -> ByteString -> Action t b m ()Source
GET /:id
id is passed in as the second parameter.
restNew :: a -> Action t b m ()Source
GET /new
restCreate :: a -> Action t b m ()Source
POST /
restEdit :: a -> ByteString -> Action t b m ()Source
GET /:id/edit
id is passed in as the second parameter.
restUpdate :: a -> ByteString -> Action t b m ()Source
PUT /:id
id is passed in as the second parameter.
Since PUT is not supported by many browsers, this action also responds to
requests containing the HTTP header X-HTTP-Method-Override: PUT
regardless of the actual HTTP method (GET or POST)
restDestroy :: a -> ByteString -> Action t b m ()Source
DELETE /:id
id is passed in as the second parameter.
Since DELETE is not supported by many browsers, this action also responds to
requests containing the HTTP header X-HTTP-Method-Override: DELETE
regardless of the actual HTTP method (GET or POST)
routeRestController :: RestController t b m a => String -> a -> ActionRoute b m tSource
Routes URLs under the given String to actions in a RestController. For
example
routeRestController posts myRestController
will map the follwoing URLs:
- GET /posts => myRestController#restIndex
- POST /posts => myRestController#restCreate
- GET /posts/:id => myRestController#restShow
- GET /posts/:id/edit => myRestController#restEdit
- GET /posts/:id/new => myRestController#restNew
- DELETE /posts/:id => myRestController#restDestroy
- PUT /posts/:id => myRestController#restUpdate