Safe Haskell | None |
---|---|
Language | Haskell2010 |
you build your api using this stuff.
- class (Functor m, MonadIO m) => MonadRespond m where
- respond :: Response -> m ResponseReceived
- getRequest :: m Request
- getHandlers :: m FailureHandlers
- withHandlers :: (FailureHandlers -> FailureHandlers) -> m a -> m a
- getPath :: m PathConsumer
- withPath :: (PathConsumer -> PathConsumer) -> m a -> m a
- data RespondT m a
- runRespondT :: RespondT m a -> FailureHandlers -> Request -> Responder -> m a
- mapRespondT :: (m a -> n b) -> RespondT m a -> RespondT n b
- data FailureHandlers = FailureHandlers {
- _unsupportedMethod :: MonadRespond m => [StdMethod] -> Method -> m ResponseReceived
- _unmatchedPath :: MonadRespond m => m ResponseReceived
- _bodyParseFailed :: (MonadRespond m, ReportableError e) => e -> m ResponseReceived
- _authFailed :: (MonadRespond m, ReportableError e) => e -> m ResponseReceived
- _accessDenied :: (MonadRespond m, ReportableError e) => e -> m ResponseReceived
- _caughtException :: (MonadRespond m, ReportableError e) => e -> m ResponseReceived
- _unacceptableResponse :: MonadRespond m => m ResponseReceived
- unsupportedMethod :: forall m. MonadRespond m => Getter FailureHandlers ([StdMethod] -> Method -> m ResponseReceived)
- unmatchedPath :: forall m. MonadRespond m => Getter FailureHandlers (m ResponseReceived)
- bodyParseFailed :: forall e m. (MonadRespond m, ReportableError e) => Getter FailureHandlers (e -> m ResponseReceived)
- authFailed :: forall e m. (MonadRespond m, ReportableError e) => Getter FailureHandlers (e -> m ResponseReceived)
- accessDenied :: forall e m. (MonadRespond m, ReportableError e) => Getter FailureHandlers (e -> m ResponseReceived)
- caughtException :: forall e m. (MonadRespond m, ReportableError e) => Getter FailureHandlers (e -> m ResponseReceived)
- unacceptableResponse :: forall m. MonadRespond m => Getter FailureHandlers (m ResponseReceived)
the monad interface
class (Functor m, MonadIO m) => MonadRespond m where Source
this class is the api for building your handler.
respond :: Response -> m ResponseReceived Source
perform the WAI application respond action (after converting the value to a response)
getRequest :: m Request Source
get out the request.
getHandlers :: m FailureHandlers Source
get the FailureHandlers
.
withHandlers :: (FailureHandlers -> FailureHandlers) -> m a -> m a Source
run an inner action that will see an updates set of error handlers. this is useful when you know that inner actions will need to do resource cleanup or something.
getPath :: m PathConsumer Source
get the path as it's been consumed so far.
withPath :: (PathConsumer -> PathConsumer) -> m a -> m a Source
run the inner action with an updated path state.
MonadRespond m => MonadRespond (MaybeT m) | |
(Functor m, MonadIO m) => MonadRespond (RespondT m) | |
MonadRespond m => MonadRespond (ExceptT e m) |
an implementation
RespondT is a monad transformer that provides an implementation of MonadRespond. you build your application using this.
MonadTrans RespondT | |
MonadTransControl RespondT | |
MonadBaseControl b m => MonadBaseControl b (RespondT m) | |
MonadBase b m => MonadBase b (RespondT m) | |
Monad m => Monad (RespondT m) | |
Functor m => Functor (RespondT m) | |
Applicative m => Applicative (RespondT m) | |
MonadThrow m => MonadThrow (RespondT m) | |
MonadCatch m => MonadCatch (RespondT m) | |
MonadLogger m => MonadLogger (RespondT m) | |
MonadIO m => MonadIO (RespondT m) | |
(Functor m, MonadIO m) => MonadRespond (RespondT m) | |
data StT RespondT = StRespond {
| |
data StM (RespondT m) = StMT {} |
runRespondT :: RespondT m a -> FailureHandlers -> Request -> Responder -> m a Source
run the RespondT action with failure handlers and request information.
mapRespondT :: (m a -> n b) -> RespondT m a -> RespondT n b Source
handling errors
data FailureHandlers Source
record containing responders that request matching tools can use when failures occur.
FailureHandlers | |
|
Getters for each handler
unsupportedMethod :: forall m. MonadRespond m => Getter FailureHandlers ([StdMethod] -> Method -> m ResponseReceived) Source
unmatchedPath :: forall m. MonadRespond m => Getter FailureHandlers (m ResponseReceived) Source
bodyParseFailed :: forall e m. (MonadRespond m, ReportableError e) => Getter FailureHandlers (e -> m ResponseReceived) Source
authFailed :: forall e m. (MonadRespond m, ReportableError e) => Getter FailureHandlers (e -> m ResponseReceived) Source
accessDenied :: forall e m. (MonadRespond m, ReportableError e) => Getter FailureHandlers (e -> m ResponseReceived) Source
caughtException :: forall e m. (MonadRespond m, ReportableError e) => Getter FailureHandlers (e -> m ResponseReceived) Source
unacceptableResponse :: forall m. MonadRespond m => Getter FailureHandlers (m ResponseReceived) Source