| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Yesod.Core.Content
Contents
Synopsis
- 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
- toFlushBuilder :: a -> Flush Builder
- 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
- toTypedContent :: a -> TypedContent
- class ToTypedContent a => HasContentType a where
- getContentType :: Monad m => m a -> ContentType
- 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
Constructors
| ContentBuilder !Builder !(Maybe Int) | The content and optional content length. |
| ContentSource !(ConduitT () (Flush Builder) (ResourceT IO) ()) | |
| ContentFile !FilePath !(Maybe FilePart) | |
| ContentDontEvaluate !Content |
Instances
| IsString Content Source # | |
Defined in Yesod.Core.Types Methods fromString :: String -> Content # | |
| ToContent Content Source # | |
| ToTypedContent (ContentType, Content) Source # | |
Defined in Yesod.Core.Content Methods toTypedContent :: (ContentType, Content) -> TypedContent Source # | |
| ToContent (ContentType, Content) Source # | |
Defined in Yesod.Core.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.
Instances
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
Methods
toFlushBuilder :: a -> Flush Builder Source #
Instances
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
Constructors
| DontFullyEvaluate | |
Fields
| |
Instances
| ToTypedContent a => ToTypedContent (DontFullyEvaluate a) Source # | |
Defined in Yesod.Core.Content Methods toTypedContent :: DontFullyEvaluate a -> TypedContent Source # | |
| HasContentType a => HasContentType (DontFullyEvaluate a) Source # | |
Defined in Yesod.Core.Content Methods getContentType :: Monad m => m (DontFullyEvaluate a) -> ContentType Source # | |
| ToContent a => ToContent (DontFullyEvaluate a) Source # | |
Defined in Yesod.Core.Content Methods toContent :: DontFullyEvaluate a -> Content Source # | |
Representations
data TypedContent Source #
Constructors
| TypedContent !ContentType !Content |
Instances
| ToTypedContent TypedContent Source # | |
Defined in Yesod.Core.Content Methods | |
| ToContent TypedContent Source # | |
Defined in Yesod.Core.Content Methods toContent :: TypedContent -> Content Source # | |
class ToContent a => ToTypedContent a where Source #
Any type which can be converted to TypedContent.
Since 1.2.0
Methods
toTypedContent :: a -> TypedContent Source #
Instances
class ToTypedContent a => HasContentType a where Source #
Methods
getContentType :: Monad m => m a -> ContentType Source #
Instances
Specific content types
Instances
| ToTypedContent RepJson Source # | |
Defined in Yesod.Core.Content Methods toTypedContent :: RepJson -> TypedContent Source # | |
| HasContentType RepJson Source # | |
Defined in Yesod.Core.Content Methods getContentType :: Monad m => m RepJson -> ContentType Source # | |
| ToContent RepJson Source # | |
Instances
| ToTypedContent RepPlain Source # | |
Defined in Yesod.Core.Content Methods | |
| HasContentType RepPlain Source # | |
Defined in Yesod.Core.Content Methods getContentType :: Monad m => m RepPlain -> ContentType Source # | |
| ToContent RepPlain Source # | |
Instances
| ToTypedContent RepXml Source # | |
Defined in Yesod.Core.Content Methods toTypedContent :: RepXml -> TypedContent Source # | |
| HasContentType RepXml Source # | |
Defined in Yesod.Core.Content Methods getContentType :: Monad m => m RepXml -> ContentType Source # | |
| ToContent RepXml Source # | |