Safe Haskell | None |
---|
- data Content
- = ContentBuilder !Builder !(Maybe Int)
- | ContentSource !(Source (ResourceT IO) (Flush Builder))
- | ContentFile !FilePath !(Maybe FilePart)
- | ContentDontEvaluate !Content
- emptyContent :: Content
- class ToContent a where
- type ContentType = ByteString
- typeHtml :: ContentType
- typePlain :: ContentType
- typeJson :: ContentType
- typeXml :: ContentType
- typeAtom :: ContentType
- typeRss :: ContentType
- typeJpeg :: ContentType
- typePng :: ContentType
- typeGif :: ContentType
- typeSvg :: ContentType
- typeJavascript :: ContentType
- typeCss :: ContentType
- typeFlv :: ContentType
- typeOgv :: ContentType
- typeOctet :: ContentType
- simpleContentType :: ContentType -> ContentType
- newtype DontFullyEvaluate a = DontFullyEvaluate a
- 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 -> Text
- formatRFC1123 :: UTCTime -> Text
- formatRFC822 :: UTCTime -> Text
Content
ContentBuilder !Builder !(Maybe Int) | The content and optional content length. |
ContentSource !(Source (ResourceT IO) (Flush Builder)) | |
ContentFile !FilePath !(Maybe FilePart) | |
ContentDontEvaluate !Content |
Zero-length enumerator.
Anything which can be converted into Content
. Most of the time, you will
want to use the ContentBuilder
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.
Please note that the built-in instances for lazy data structures (String
,
lazy ByteString
, lazy Text
and Html
) will not automatically include
the content length for the ContentBuilder
constructor.
Mime types
Data type
type ContentType = ByteStringSource
Utilities
simpleContentType :: ContentType -> ContentTypeSource
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".
Evaluation strategy
newtype DontFullyEvaluate a Source
Prevents a response body from being fully evaluated before sending the request.
Since 1.1.0
HasReps a => HasReps (DontFullyEvaluate a) | |
ToContent a => ToContent (DontFullyEvaluate a) |
Representations
= [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
Utilities
formatRFC1123 :: UTCTime -> TextSource
Format as per RFC 1123.
formatRFC822 :: UTCTime -> TextSource
Format as per RFC 822.