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

Yesod.Content

Contents

Synopsis

Content

emptyContent :: ContentSource

Zero-length enumerator.

class ToContent a whereSource

Anything which can be converted into Content. Most of the time, you will want to use the ContentEnum constructor. An easier approach will be to use a pre-defined toContent function, such as converting your data into a lazy bytestring and then calling toContent on that.

Methods

toContent :: a -> ContentSource

Mime types

Data type

File extensions

typeByExt :: [(String, ContentType)]Source

A default extension to mime-type dictionary.

ext :: String -> StringSource

Get a file extension (everything after last period).

Utilities

simpleContentType :: String -> StringSource

Removes "extra" information at the end of a content type string. In particular, removes everything after the semicolon, if present.

For example, "text/html; charset=utf-8" is commonly used to specify the character encoding for HTML data. This function would return "text/html".

Representations

type ChooseRepSource

Arguments

 = [ContentType]

list of content-types user accepts, ordered by preference

-> IO (ContentType, Content) 

A function which gives targetted representations of content based on the content-types the user accepts.

class HasReps a whereSource

Any type which can be converted to representations.

Methods

chooseRep :: a -> ChooseRepSource

defChooseRep :: [(ContentType, a -> IO Content)] -> a -> ChooseRepSource

A helper method for generating HasReps instances.

This function should be given a list of pairs of content type and conversion functions. If none of the content types match, the first pair is used.

Specific content types

newtype RepHtml Source

Constructors

RepHtml Content 

Instances

newtype RepJson Source

Constructors

RepJson Content 

Instances

newtype RepPlain Source

Constructors

RepPlain Content 

Instances

newtype RepXml Source

Constructors

RepXml Content 

Instances

Utilities

formatW3 :: UTCTime -> StringSource

Format a UTCTime in W3 format; useful for setting cookies.

formatRFC1123 :: UTCTime -> StringSource

Format as per RFC 1123.