yesod-0.5.4: Creation of type-safe, RESTful web applications.

Yesod.Request

Contents

Description

Provides a parsed version of the raw Request data.

Synopsis

Request datatype

type RequestBodyContents = ([(ParamName, ParamValue)], [(ParamName, FileInfo)])Source

A tuple containing both the POST parameters and submitted files.

data Request Source

The parsed request information.

Constructors

Request 

Fields

reqGetParams :: [(ParamName, ParamValue)]
 
reqCookies :: [(ParamName, ParamValue)]
 
reqSession :: [(ParamName, ParamValue)]

Session data stored in a cookie via the clientsession package.

reqRequestBody :: IO RequestBodyContents

The POST parameters and submitted files. This is stored in an IO thunk, which essentially means it will be computed once at most, but only if requested. This allows avoidance of the potentially costly parsing of POST bodies for pages which do not use them.

reqWaiRequest :: Request
 
reqLangs :: [String]

Languages which the client supports.

Instances

class Monad m => RequestReader m whereSource

The reader monad specialized for Request.

Instances

Convenience functions

waiRequest :: RequestReader m => m RequestSource

Get the request's Request value.

languages :: RequestReader m => m [String]Source

Get the list of supported languages supplied by the user.

Languages are determined based on the following three (in descending order of preference):

  • The _LANG get parameter.
  • The _LANG cookie.
  • The _LANG user session variable.
  • Accept-Language HTTP header.

This is handled by the parseWaiRequest function in Yesod.Dispatch (not exposed).

Lookup parameters

lookupGetParam :: RequestReader m => ParamName -> m (Maybe ParamValue)Source

Lookup for GET parameters.

lookupCookie :: RequestReader m => ParamName -> m (Maybe ParamValue)Source

Lookup for cookie data.

lookupSession :: RequestReader m => ParamName -> m (Maybe ParamValue)Source

Lookup for session data.

lookupFile :: (MonadIO m, RequestReader m) => ParamName -> m (Maybe FileInfo)Source

Lookup for POSTed files.

Multi-lookup

lookupGetParams :: RequestReader m => ParamName -> m [ParamValue]Source

Lookup for GET parameters.

lookupPostParams :: (MonadIO m, RequestReader m) => ParamName -> m [ParamValue]Source

Lookup for POST parameters.

lookupCookies :: RequestReader m => ParamName -> m [ParamValue]Source

Lookup for cookie data.

lookupSessions :: RequestReader m => ParamName -> m [ParamValue]Source

Lookup for session data.

lookupFiles :: (MonadIO m, RequestReader m) => ParamName -> m [FileInfo]Source

Lookup for POSTed files.

Parameter type synonyms