Portability | non-portable |
---|---|
Stability | experimental |
Maintainer | Anders Kaseorg <andersk@mit.edu> |
Safe Haskell | None |
Network.CGI.Monad
Description
Internal stuff that most people shouldn't have to use. This module mostly deals with the internals of the CGIT monad transformer.
- class Monad m => MonadCGI m where
- cgiAddHeader :: HeaderName -> String -> m ()
- cgiGet :: (CGIRequest -> a) -> m a
- newtype CGIT m a = CGIT {
- unCGIT :: ReaderT CGIRequest (WriterT Headers m) a
- type CGI a = CGIT IO a
- runCGIT :: Monad m => CGIT m a -> CGIRequest -> m (Headers, a)
- data CGIRequest = CGIRequest {
- cgiVars :: Map String String
- cgiInputs :: [(String, Input)]
- cgiRequestBody :: ByteString
- throwCGI :: (MonadCGI m, MonadIO m) => SomeException -> m a
- catchCGI :: CGI a -> (SomeException -> CGI a) -> CGI a
- tryCGI :: CGI a -> CGI (Either SomeException a)
- handleExceptionCGI :: CGI a -> (SomeException -> CGI a) -> CGI a
CGI monad class
class Monad m => MonadCGI m whereSource
The class of CGI monads. Most CGI actions can be run in any monad which is an instance of this class, which means that you can use your own monad transformers to add extra functionality.
Methods
cgiAddHeader :: HeaderName -> String -> m ()Source
Add a response header.
cgiGet :: (CGIRequest -> a) -> m aSource
Get something from the CGI request.
CGI monad transformer
The CGIT monad transformer.
runCGIT :: Monad m => CGIT m a -> CGIRequest -> m (Headers, a)Source
Run a CGI action.
Request info
data CGIRequest Source
The input to a CGI action.
Constructors
CGIRequest | |
Fields
|
Instances
Show CGIRequest |
Error handling
throwCGI :: (MonadCGI m, MonadIO m) => SomeException -> m aSource
Throw an exception in a CGI monad. The monad is required to be
a MonadIO
, so that we can use throwIO
to guarantee ordering.
catchCGI :: CGI a -> (SomeException -> CGI a) -> CGI aSource
Catches any expection thrown by a CGI action, and uses the given exception handler if an exception is thrown.