Safe Haskell | None |
---|---|
Language | Haskell98 |
Handlers for endpoints in a Resource
.
- mkHandler :: (Monad m, i ~ FromMaybe () i', o ~ FromMaybe () o', e ~ FromMaybe Void e') => Modifier h p i' o' e' -> (Env h p i -> ExceptT (Reason e) m o) -> Handler m
- mkInputHandler :: (Monad m, i ~ FromMaybe () i', o ~ FromMaybe () o', e ~ FromMaybe Void e') => Modifier () () i' o' e' -> (i -> ExceptT (Reason e) m o) -> Handler m
- mkConstHandler :: (Monad m, o ~ FromMaybe () o', e ~ FromMaybe Void e') => Modifier () () Nothing o' e' -> ExceptT (Reason e) m o -> Handler m
- mkIdHandler :: (MonadReader id m, i ~ FromMaybe () i', o ~ FromMaybe () o', e ~ FromMaybe Void e') => Modifier h p i' o' e' -> (i -> id -> ExceptT (Reason e) m o) -> Handler m
- mkListing :: (Monad m, o ~ FromMaybe () o', e ~ FromMaybe Void e') => Modifier h p Nothing o' e' -> (Range -> ExceptT (Reason e) m [o]) -> ListHandler m
- mkOrderedListing :: (Monad m, o ~ FromMaybe () o', e ~ FromMaybe Void e') => Modifier h p Nothing o' e' -> ((Range, Maybe String, Maybe String) -> ExceptT (Reason e) m [o]) -> ListHandler m
- data Range :: * = Range {}
- range :: Param Range
- orderedRange :: Param (Range, Maybe String, Maybe String)
- data Env h p i = Env {}
- data GenHandler m f where
- GenHandler :: (i ~ FromMaybe () i', o ~ FromMaybe () o', e ~ FromMaybe Void e') => {..} -> GenHandler m f
- mkGenHandler :: (Monad m, i ~ FromMaybe () i', o ~ FromMaybe () o', e ~ FromMaybe Void e') => Modifier h p i' o' e' -> (Env h p i -> ExceptT (Reason e) m (Apply f o)) -> GenHandler m f
- type family Apply (f :: * -> *) a :: *
- type Handler m = GenHandler m Identity
- type ListHandler m = GenHandler m []
- secureHandler :: Handler m -> Handler m
Single handlers.
mkHandler :: (Monad m, i ~ FromMaybe () i', o ~ FromMaybe () o', e ~ FromMaybe Void e') => Modifier h p i' o' e' -> (Env h p i -> ExceptT (Reason e) m o) -> Handler m Source #
Create a handler for a single resource. Takes the entire environmend as input.
mkInputHandler :: (Monad m, i ~ FromMaybe () i', o ~ FromMaybe () o', e ~ FromMaybe Void e') => Modifier () () i' o' e' -> (i -> ExceptT (Reason e) m o) -> Handler m Source #
Create a handler for a single resource. Takes only the body information as input.
mkConstHandler :: (Monad m, o ~ FromMaybe () o', e ~ FromMaybe Void e') => Modifier () () Nothing o' e' -> ExceptT (Reason e) m o -> Handler m Source #
Create a handler for a single resource. Doesn't take any input.
mkIdHandler :: (MonadReader id m, i ~ FromMaybe () i', o ~ FromMaybe () o', e ~ FromMaybe Void e') => Modifier h p i' o' e' -> (i -> id -> ExceptT (Reason e) m o) -> Handler m Source #
Create a handler for a single resource. Take body information and
the resource identifier as input. The monad m
must be a
Reader
-like type containing the idenfier.
Listings.
mkListing :: (Monad m, o ~ FromMaybe () o', e ~ FromMaybe Void e') => Modifier h p Nothing o' e' -> (Range -> ExceptT (Reason e) m [o]) -> ListHandler m Source #
mkOrderedListing :: (Monad m, o ~ FromMaybe () o', e ~ FromMaybe Void e') => Modifier h p Nothing o' e' -> ((Range, Maybe String, Maybe String) -> ExceptT (Reason e) m [o]) -> ListHandler m Source #
Parameter parsers for listings.
Data type for representing the requested range in list handlers.
Dictionary for taking Range
parameters. Allows two query
parameters, offset
and count
. If not passed, the defaults are 0
and 100. The maximum range that can be passed is 1000.
orderedRange :: Param (Range, Maybe String, Maybe String) Source #
Dictionary for taking ordering information. In addition to the
parameters accepted by range
, this accepts order
and
direction
.
Generic handlers and core data types.
data GenHandler m f where Source #
A handler for some endpoint. The input and output types are
specified by the dictionary
, which can be created using the
combinators from Rest.Dictionary.Combinators. The inputs
(headers, parameters and body) are passed as an Env
to the
handler
. This handler runs in monad m
, combined with the
ability to throw errors. The result is either the output value, or
a list of them for list handlers.
If the secure
flag is set, this suggests to clients that the
resource should only be served over https. It has no effect when
running the API.
GenHandler :: (i ~ FromMaybe () i', o ~ FromMaybe () o', e ~ FromMaybe Void e') => {..} -> GenHandler m f | |
mkGenHandler :: (Monad m, i ~ FromMaybe () i', o ~ FromMaybe () o', e ~ FromMaybe Void e') => Modifier h p i' o' e' -> (Env h p i -> ExceptT (Reason e) m (Apply f o)) -> GenHandler m f Source #
Construct a GenHandler
using a Modifier
instead of a Dict
.
The secure
flag will be False
.
type ListHandler m = GenHandler m [] Source #
A Handler
returning a list of items.