Yesod.Content
Contents
- type Content = ResponseBody
- emptyContent :: Content
- class ToContent a where
- type ContentType = String
- typeHtml :: ContentType
- typePlain :: ContentType
- typeJson :: ContentType
- typeXml :: ContentType
- typeAtom :: ContentType
- typeJpeg :: ContentType
- typePng :: ContentType
- typeGif :: ContentType
- typeJavascript :: ContentType
- typeCss :: ContentType
- typeFlv :: ContentType
- typeOgv :: ContentType
- typeOctet :: ContentType
- typeByExt :: [(String, ContentType)]
- ext :: String -> String
- simpleContentType :: String -> String
- type ChooseRep = [ContentType] -> IO (ContentType, Content)
- class HasReps a where
- defChooseRep :: [(ContentType, a -> IO Content)] -> a -> ChooseRep
- newtype RepHtml = RepHtml Content
- newtype RepJson = RepJson Content
- data RepHtmlJson = RepHtmlJson Content Content
- newtype RepPlain = RepPlain Content
- newtype RepXml = RepXml Content
- formatW3 :: UTCTime -> String
- formatRFC1123 :: UTCTime -> String
- formatCookieExpires :: UTCTime -> String
Content
type Content = ResponseBodySource
Zero-length enumerator.
Mime types
Data type
type ContentType = StringSource
File extensions
typeByExt :: [(String, ContentType)]Source
A default extension to mime-type dictionary.
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
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.
Any type which can be converted to representations.
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
data RepHtmlJson Source
Constructors
RepHtmlJson Content Content |
Utilities
formatRFC1123 :: UTCTime -> StringSource
Format as per RFC 1123.
formatCookieExpires :: UTCTime -> StringSource
Format a UTCTime
for a cookie.