yesod-0.6.1.2: 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)]
 
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.

reqNonce :: String

A random, session-specific nonce used to prevent CSRF attacks.

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.

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.

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

Lookup for POSTed files.

Parameter type synonyms