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

Yesod.Request

Contents

- Request datatype
- Convenience functions
- Lookup parameters
  - Multi-lookup

Description

Provides a parsed version of the raw `W.Request` data.

Synopsis

- type RequestBodyContents = ([(Text, Text)], [(Text, FileInfo)])
- data Request = Request {
  - reqGetParams :: [(Text, Text)]
  - reqCookies :: [(Text, Text)]
  - reqWaiRequest :: Request
  - reqLangs :: [Text]
  - reqNonce :: Maybe Text
  }
- data FileInfo = FileInfo {
  - fileName :: Text
  - fileContentType :: Text
  - fileContent :: ByteString
  }
- languages :: Monad mo => GGHandler s m mo [Text]
- lookupGetParam :: Monad mo => Text -> GGHandler s m mo (Maybe Text)
- lookupPostParam :: Text -> GHandler s m (Maybe Text)
- lookupCookie :: Monad mo => Text -> GGHandler s m mo (Maybe Text)
- lookupFile :: Text -> GHandler s m (Maybe FileInfo)
- lookupGetParams :: Monad mo => Text -> GGHandler s m mo [Text]
- lookupPostParams :: Text -> GHandler s m [Text]
- lookupCookies :: Monad mo => Text -> GGHandler s m mo [Text]
- lookupFiles :: Text -> GHandler s m [FileInfo]

# Request datatype

type RequestBodyContents = ([(Text, Text)], [(Text, FileInfo)])

A tuple containing both the POST parameters and submitted files.

data Request

The parsed request information.

Constructors

Request |

Fields

reqGetParams :: [(Text, Text)]
reqCookies :: [(Text, Text)]
reqWaiRequest :: Request
reqLangs :: [Text]

  Languages which the client supports.

reqNonce :: Maybe Text

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

data FileInfo

Constructors

FileInfo |

Fields

fileName :: Text
fileContentType :: Text
fileContent :: ByteString

Instances

Eq FileInfo |
Show FileInfo |

# Convenience functions

languages :: Monad mo => GGHandler s m mo [Text]

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 parseWaiRequest (not exposed).

# Lookup parameters

lookupGetParam :: Monad mo => Text -> GGHandler s m mo (Maybe Text)

Lookup for GET parameters.

lookupPostParam :: Text -> GHandler s m (Maybe Text)

lookupCookie :: Monad mo => Text -> GGHandler s m mo (Maybe Text)

Lookup for cookie data.

lookupFile :: Text -> GHandler s m (Maybe FileInfo)

Lookup for POSTed files.

## Multi-lookup

lookupGetParams :: Monad mo => Text -> GGHandler s m mo [Text]

Lookup for GET parameters.

lookupPostParams :: Text -> GHandler s m [Text]

Lookup for POST parameters.

lookupCookies :: Monad mo => Text -> GGHandler s m mo [Text]

Lookup for cookie data.

lookupFiles :: Text -> GHandler s m [FileInfo]

Lookup for POSTed files.