| Safe Haskell | Trustworthy |
|---|
Hails.Web.Controller
Description
This module exports a definition of a Controller, which is simply a
DC action with the Labeled HTTP Request in the environment
(i.e., it is a Reader monad).
- type Controller = ReaderT ControllerState DC
- data ControllerState = ControllerState {}
- request :: Controller (DCLabeled Request)
- requestHeader :: HeaderName -> Controller (Maybe ByteString)
- body :: Controller ByteString
- queryParam :: ByteString -> Controller (Maybe ByteString)
- respond :: Routeable r => r -> Controller r
- redirectBack :: Controller Response
- redirectBackOr :: Response -> Controller Response
Documentation
type Controller = ReaderT ControllerState DCSource
request :: Controller (DCLabeled Request)Source
Get the underlying request.
requestHeader :: HeaderName -> Controller (Maybe ByteString)Source
Get a request header
body :: Controller ByteStringSource
Extract the body in the request (after unlabeling it).
queryParam :: ByteString -> Controller (Maybe ByteString)Source
Get the query parameter mathing the supplied variable name.
respond :: Routeable r => r -> Controller rSource
Produce a response.
redirectBack :: Controller ResponseSource
Redirect back acording to the referer header. If the header is
not present redirect to root (i.e., /).
redirectBackOr :: Response -> Controller ResponseSource
Redirect back acording to the referer header. If the header is not present return the given response.