Safe Haskell | None |
---|---|
Language | Haskell98 |
- data Content
- = ContentBuilder !Builder !(Maybe Int)
- | ContentSource !(ConduitT () (Flush Builder) (ResourceT IO) ())
- | ContentFile !FilePath !(Maybe FilePart)
- | ContentDontEvaluate !Content
- emptyContent :: Content
- class ToContent a where
- class ToFlushBuilder 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
- contentTypeTypes :: ContentType -> (ByteString, ByteString)
- newtype DontFullyEvaluate a = DontFullyEvaluate {
- unDontFullyEvaluate :: a
- data TypedContent = TypedContent !ContentType !Content
- class ToContent a => ToTypedContent a where
- class ToTypedContent a => HasContentType a where
- type RepHtml = Html
- newtype RepJson = RepJson Content
- newtype RepPlain = RepPlain Content
- newtype RepXml = RepXml Content
- repJson :: ToContent a => a -> RepJson
- repPlain :: ToContent a => a -> RepPlain
- repXml :: ToContent a => a -> RepXml
Content
ContentBuilder !Builder !(Maybe Int) | The content and optional content length. |
ContentSource !(ConduitT () (Flush Builder) (ResourceT IO) ()) | |
ContentFile !FilePath !(Maybe FilePart) | |
ContentDontEvaluate !Content |
emptyContent :: Content Source #
Zero-length enumerator.
class ToContent a where Source #
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.
ToContent () Source # | |
ToContent ByteString Source # | |
ToContent ByteString Source # | |
ToContent Builder Source # | |
ToContent String Source # | |
ToContent Text Source # | |
ToContent Encoding Source # | |
ToContent Value Source # | |
ToContent Text Source # | |
ToContent Html Source # | |
ToContent Css Source # | |
ToContent Javascript Source # | |
ToContent RepXml Source # | |
ToContent RepPlain Source # | |
ToContent RepJson Source # | |
ToContent TypedContent Source # | |
ToContent Content Source # | |
ToContent a => ToContent (DontFullyEvaluate a) Source # | |
ToContent (ContentType, Content) Source # | |
ToFlushBuilder builder => ToContent (ConduitT () builder (ResourceT IO) ()) Source # | |
ToFlushBuilder builder => ToContent (SealedConduitT () builder (ResourceT IO) ()) Source # | |
ToFlushBuilder builder => ToContent (Pipe () () builder () (ResourceT IO) ()) Source # | |
class ToFlushBuilder a where Source #
A class for all data which can be sent in a streaming response. Note that for textual data, instances must use UTF-8 encoding.
Since 1.2.0
toFlushBuilder :: a -> Flush Builder Source #
Mime types
Data type
type ContentType = ByteString Source #
Utilities
simpleContentType :: ContentType -> ContentType Source #
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".
contentTypeTypes :: ContentType -> (ByteString, ByteString) Source #
Give just the media types as a pair.
For example, "text/html; charset=utf-8" returns ("text", "html")
Evaluation strategy
newtype DontFullyEvaluate a Source #
Prevents a response body from being fully evaluated before sending the request.
Since 1.1.0
ToTypedContent a => ToTypedContent (DontFullyEvaluate a) Source # | |
HasContentType a => HasContentType (DontFullyEvaluate a) Source # | |
ToContent a => ToContent (DontFullyEvaluate a) Source # | |
Representations
data TypedContent Source #
class ToContent a => ToTypedContent a where Source #
Any type which can be converted to TypedContent
.
Since 1.2.0
toTypedContent :: a -> TypedContent Source #
class ToTypedContent a => HasContentType a where Source #
getContentType :: Monad m => m a -> ContentType Source #