Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- finishEarly :: MonadSnap m => Int -> ByteString -> m b
- badReq :: MonadSnap m => ByteString -> m b
- notFound :: MonadSnap m => ByteString -> m b
- serverError :: MonadSnap m => ByteString -> m b
- plainResponse :: MonadSnap m => m ()
- jsonResponse :: MonadSnap m => m ()
- jsResponse :: MonadSnap m => m ()
- easyLog :: (Show t, MonadSnap m) => String -> t -> m ()
- getParam' :: MonadSnap m => ByteString -> m (Maybe ByteString)
- reqParam :: MonadSnap m => ByteString -> m ByteString
- readParam :: (MonadSnap m, Read a) => ByteString -> m (Maybe a)
- readMayParam :: (MonadSnap m, Read a) => ByteString -> m (Maybe a)
- redirectReferer :: MonadSnap m => m b
- redirectRefererFunc :: MonadSnap m => (Maybe ByteString -> ByteString) -> m b
- dirify :: MonadSnap m => m ()
- undirify :: MonadSnap m => m ()
- maybeBadReq :: MonadSnap m => ByteString -> m (Maybe a) -> m a
- fromMaybeM :: Monad m => m a -> m (Maybe a) -> m a
- (-/-) :: ByteString -> ByteString -> ByteString
Documentation
finishEarly :: MonadSnap m => Int -> ByteString -> m b Source #
Discard anything after this and return given status code to HTTP client immediately.
badReq :: MonadSnap m => ByteString -> m b Source #
Finish early with error code 400
notFound :: MonadSnap m => ByteString -> m b Source #
Finish early with error code 404
serverError :: MonadSnap m => ByteString -> m b Source #
Finish early with error code 500
plainResponse :: MonadSnap m => m () Source #
Mark response as 'text/plain'
jsonResponse :: MonadSnap m => m () Source #
Mark response as 'application/json'
jsResponse :: MonadSnap m => m () Source #
Mark response as 'application/javascript'
easyLog :: (Show t, MonadSnap m) => String -> t -> m () Source #
Easier debug logging into error log. First argument is a
category/namespace and the second argument is anything that has a
Show
instance.
getParam' :: MonadSnap m => ByteString -> m (Maybe ByteString) Source #
Alternate version of getParam that considers empty string Nothing
reqParam :: MonadSnap m => ByteString -> m ByteString Source #
Require that a parameter is present or terminate early.
readParam :: (MonadSnap m, Read a) => ByteString -> m (Maybe a) Source #
Read a parameter from request. Be sure it is readable if it's there, or else this will raise an error.
readMayParam :: (MonadSnap m, Read a) => ByteString -> m (Maybe a) Source #
Try to read a parameter from request. Computation may fail because the param is not there, or because it can't be read.
redirectReferer :: MonadSnap m => m b Source #
Redirects back to the refering page. If there is no Referer header, then redirect to /.
redirectRefererFunc :: MonadSnap m => (Maybe ByteString -> ByteString) -> m b Source #
Redirects back to the refering page. If there is no Referer header, then redirect to /.
dirify :: MonadSnap m => m () Source #
If the current rqURI does not have a trailing slash, then redirect to the same page with a slash added.
undirify :: MonadSnap m => m () Source #
If the current rqURI has a trailing slash, then redirect to the same page with no trailing slash.
maybeBadReq :: MonadSnap m => ByteString -> m (Maybe a) -> m a Source #
fromMaybeM :: Monad m => m a -> m (Maybe a) -> m a Source #
Evaluates an action that returns a Maybe and
(-/-) :: ByteString -> ByteString -> ByteString Source #
Concatenates two URL segments with a /
between them. To prevent double
slashes, all trailing slashes are removed from the first path and all
leading slashes are removed from the second path.