hails-0.9.2.1: Multi-app web platform framework

Safe HaskellTrustworthy

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).

Synopsis

Documentation

type Controller = ReaderT ControllerState DCSource

A controller is simply a reader monad atop DC with the Labeled Request as the environment.

request :: Controller (DCLabeled Request)Source

Get the underlying request.

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.