The class ToTypedContent
describes what content-type
data is. Thus, types that have an associated content type (e.g., UTF 8 for Text
or Value
(JSON)) can have a natural instance ToTypedContent
.
The problem with it ByteString
is that it describes any binary data - yours ByteString
could be PNG, JPEG or something else, so it is not clear what type of content it should provide.
, octet-stream
:
getHomeR :: Handler TypedContent
getHomeR = return $ TypedContent typeOctet $ toContent ("x" :: ByteString)
, (, image/jpeg
JPEG).
TypedContent
, , ToTypedContent
ByteString
newtype Jpeg = Jpeg ByteString deriving (Show, ToContent)
instance ToTypedContent Jpeg where
toTypedContent h = TypedContent "image/jpeg" (toContent h)