hails-0.11.2.1: Multi-app web platform framework

Safe HaskellSafe
LanguageHaskell98

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 DC Source

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 ByteString Source

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 r Source

Produce a response.

redirectBack :: Controller Response Source

Redirect back acording to the referer header. If the header is not present redirect to root (i.e., /).

redirectBackOr :: Response -> Controller Response Source

Redirect back acording to the referer header. If the header is not present return the given response.