iterio-server-0.2: Library for building servers with IterIO

Safe HaskellSafe-Infered

Data.IterIO.Http.Support.Action

Description

Defines the Action monad which abstracts some of the details of handling HTTP requests with IterIO.

Synopsis

Documentation

type Action t m a = StateT (HttpReq t, HttpResp m, [Param]) m aSource

A StateT monad in which requests can be handled. It keeps track of the HttpReq, the form parameters from the request body and an HttpResp used to reply to the client.

data Param Source

A request parameter from a form field in the HTTP body

Constructors

Param 

Fields

paramKey :: ByteString
 
paramValue :: ByteString
 
paramHeaders :: [(ByteString, ByteString)]

Header of a multipart/form-data post

routeAction :: Monad m => Action t m () -> HttpRoute m tSource

Routes an Action

routeActionPattern :: Monad m => String -> Action t m () -> HttpRoute m tSource

Routes an Action to the given URL pattern. Patterns can include directories as well as variable patterns (prefixed with :) to be passed into the Action as extra Params. Some examples of URL patters:

  • /posts/:id
  • /posts/:id/new
  • /:date/posts/:category/new

params :: Monad m => Action t m [Param]Source

Returns a list of all Params.

param :: Monad m => ByteString -> Action t m (Maybe Param)Source

Returns the Param corresponding to the specified key or Nothing if one is not present in the request.

getHttpReq :: Monad m => Action t m (HttpReq t)Source

Returns the HttpReq for the current request.

setSession :: Monad m => String -> Action t m ()Source

Sets a the value for "_sess" in the cookie to the given string.

destroySession :: Monad m => Action t m ()Source

Removes the "_sess" key-value pair from the cookie.

requestHeader :: Monad m => ByteString -> Action t m (Maybe ByteString)Source

Returns the value of an Http Header from the request if it exists otherwise Nothing