-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A convention-based RESTful routing mechanism for snap @package restful-snap @version 0.2 module Snap.Restful -- | One-stop convenience function to enable RESTful resources in your -- application. Call this function from your initializer passing it all -- of your resources and it will add the routes and splices for you. addResource :: HasHeist b => Resource -> [(CRUD, Handler b v ())] -> [(Text, Handler b v ())] -> [(Text, Handler b v ())] -> Snaplet (Heist b) -> Initializer b v () -- | Just like addResource, but makes the handlers relative to the -- current snaplet's root. Use this function if you're writing a snaplet. addResourceRelative :: HasHeist b => Resource -> [(CRUD, Handler b v ())] -> [(Text, Handler b v ())] -> [(Text, Handler b v ())] -> Snaplet (Heist b) -> Initializer b v () -- | An initializer for encapsulating RESTful resources as a standalone -- snaplet. initRest :: HasHeist b => Resource -> [(CRUD, Handler b () ())] -> [(Text, Handler b () ())] -> [(Text, Handler b () ())] -> Snaplet (Heist b) -> SnapletInit b () -- | Paths at the resource/collection level resourceSplices :: Monad m => Resource -> [(Text, HeistT n m Template)] -- | Generates path splices for a resource item. These splices let you put -- resource links in your templates in DRY manner. itemSplices :: Monad m => Resource -> DBId -> [(Text, Splice m)] -- | Returns compiled splices for a resource. resourceCSplices :: MonadSnap m => Resource -> [(Text, Splice m)] -- | Generates compiled path splices for a resource item. These splices let -- you put resource links in your templates in DRY manner. itemCSplices :: Resource -> [(Text, DBId -> Text)] -- | Since initRest returns unit, we provide a generic unit lens -- here for use with nestSnaplet in case you don't want to add a unit -- field to your application state type. unitLens :: Lens' b () -- | Generate a route handler for the routes returned by resourceRoutes. -- This function does add the rRoot prefix. resourceRouter :: MonadSnap m => Resource -> [(CRUD, m a)] -> [(Text, m a)] -> [(Text, m a)] -> m a -- | See addResource for an explanation of the arguments to this -- function. The routes returned ARE prefixed with rRoot from Resource. resourceRoutes :: MonadSnap m => Resource -> [(CRUD, m a)] -> [(Text, m a)] -> [(Text, m a)] -> [(ByteString, m a)] -- | Enumeration of all the different types of CRUD routes. data CRUD -- | An item index RIndex :: CRUD -- | A single item RShow :: CRUD -- | The form for creating a new item RNew :: CRUD -- | The form for editing an item REdit :: CRUD -- | Create a new item RCreate :: CRUD -- | Update an item RUpdate :: CRUD -- | Delete an item RDestroy :: CRUD -- | Encapsulates the data necessary to define a resource. data Resource Resource :: Text -> Text -> [Text] -> [Text] -> Resource -- | A name for this resource rName :: Resource -> Text -- | URL root for this resource rRoot :: Resource -> Text -- | Resource level routing end points rResourceEndpoints :: Resource -> [Text] -- | Item/instance level routing end points rItemEndpoints :: Resource -> [Text] newtype DBId DBId :: Word64 -> DBId unDBId :: DBId -> Word64 -- | Type class for automatic formlet generation. class HasFormlet a formlet :: (HasFormlet a, Monad m) => Formlet Text m a -- | Type class for automatic splice generation. class PrimSplice a iPrimSplice :: (PrimSplice a, Monad m) => a -> m [Node] cPrimSplice :: PrimSplice a => a -> Builder iPrimText :: Monad m => Text -> m [Node] iPrimShow :: (Monad m, Show a) => a -> m [Node] cPrimShow :: Show a => a -> Builder -- | Same as indexPath. rootPath :: Resource -> Text -- | Generates the path for the resource index. indexPath :: Resource -> Text -- | Generates the path for creating a resource. createPath :: Resource -> Text -- | Generates the path for showing a single resource item. showPath :: Resource -> DBId -> Text -- | Generates the path for a form to a new resource. newPath :: Resource -> Text -- | Generates the path for a form to a new resource. editPath :: Resource -> DBId -> Text -- | Generates the path for updating a single resource item. updatePath :: Resource -> DBId -> Text -- | Generates the path for deleting a resource item. destroyPath :: Resource -> DBId -> Text -- | Generates a path for an item action. itemActionPath :: Resource -> Text -> DBId -> Text -- | Return heist template location for given crud action templatePath :: Resource -> CRUD -> ByteString -- | Redirect to given item's default show page redirToItem :: MonadSnap m => Resource -> DBId -> m a -- | Adds a prefix to the tag names for a list of splices. If the existing -- tag name is empty, then the new tag name is just the prefix. Otherwise -- the new tag name is the prefix followed by an underscore followed by -- the existing name. prefixSplices :: Text -> [(Text, a)] -> [(Text, a)] relativeRedirect :: MonadSnap m => ByteString -> m b -- | Sets the RESTFormAction param. setFormAction :: MonadSnap m => Text -> m a -> m a -- | Gets the RESTFormAction param. getFormAction :: MonadSnap m => HeistT n m [Node] -- | A simple formlet for dates that simpleDateFormlet :: Monad m => Maybe Day -> Form Text m Day instance Typeable DBId instance Eq CRUD instance Show CRUD instance Read CRUD instance Ord CRUD instance Eq DBId instance Show DBId instance Read DBId instance Ord DBId instance Num DBId instance PrimSplice a => PrimSplice (Maybe a) instance PrimSplice UTCTime instance PrimSplice Day instance PrimSplice Word64 instance PrimSplice Word32 instance PrimSplice Word16 instance PrimSplice Word8 instance PrimSplice Int64 instance PrimSplice Int32 instance PrimSplice Int16 instance PrimSplice Int8 instance PrimSplice Bool instance PrimSplice Double instance PrimSplice Float instance PrimSplice Integer instance PrimSplice Int instance PrimSplice Text instance PrimSplice String instance HasFormlet Word64 instance HasFormlet Word32 instance HasFormlet Word16 instance HasFormlet Word8 instance HasFormlet Int64 instance HasFormlet Int32 instance HasFormlet Int16 instance HasFormlet Int8 instance HasFormlet Bool instance HasFormlet Double instance HasFormlet Float instance HasFormlet Integer instance HasFormlet Int instance HasFormlet Text instance HasFormlet String instance Default Resource instance Readable DBId instance Default DBId module Snap.Restful.TH -- | Derives a HasFormlet instance for a data type. deriveHasFormlet :: Name -> Q [Dec] -- | Generates interpreted splices for a data type. All of the data type's -- fields must be instances of the PrimSplice type class. -- -- Usage: -- --
--   fooSplices :: Monad m => Foo -> [(Text, I.Splice m)]
--   fooSplices = $(iSplices ''Foo)
--   
iSplices :: Name -> Q Exp -- | Generates compiled splices for a data type. All of the data type's -- fields must be instances of the PrimSplice type class. -- -- Usage: -- --
--   fooSplices = $(cSplices ''Foo)
--   
cSplices :: Name -> Q Exp