webgear-server-1.2.0: Composable, type-safe library to build HTTP API servers
Safe HaskellSafe-Inferred
LanguageHaskell2010

WebGear.Server.MIMETypes

Description

Parsing and rendering of MIME types

Synopsis

Parsing and rendering MIME types

class MIMEType mt => BodyUnrender m mt a where Source #

Instances of this class are used to parse the body of a request as specified by a MIME type.

Methods

bodyUnrender :: mt -> Request -> m (Either Text a) Source #

Parse a request body. Return a Left value with error messages in case of failure.

Instances

Instances details
(MonadIO m, FromForm a) => BodyUnrender m FormURLEncoded a Source # 
Instance details

Defined in WebGear.Server.MIMETypes

MonadIO m => BodyUnrender m HTML ByteString Source # 
Instance details

Defined in WebGear.Server.MIMETypes

MonadIO m => BodyUnrender m HTML ByteString Source # 
Instance details

Defined in WebGear.Server.MIMETypes

(MonadIO m, FromJSON a) => BodyUnrender m JSON a Source # 
Instance details

Defined in WebGear.Server.MIMETypes

Methods

bodyUnrender :: JSON -> Request -> m (Either Text a) Source #

MonadIO m => BodyUnrender m OctetStream ByteString Source # 
Instance details

Defined in WebGear.Server.MIMETypes

MonadIO m => BodyUnrender m OctetStream ByteString Source # 
Instance details

Defined in WebGear.Server.MIMETypes

(MonadIO m, FromText a) => BodyUnrender m PlainText a Source # 
Instance details

Defined in WebGear.Server.MIMETypes

MonadIO m => BodyUnrender m (FormData a) (FormDataResult a) Source # 
Instance details

Defined in WebGear.Server.MIMETypes

class MIMEType mt => BodyRender m mt a where Source #

Instances of this class serializes a value to a response body as specified by a MIME type.

Methods

bodyRender :: mt -> Response -> a -> m (MediaType, ResponseBody) Source #

Render a value in the format specified by the media type.

Returns the response body and the media type to be used in the "Content-Type" header. This could be a variant of the original media type with additional parameters.

FormData utils

inMemoryBackend :: BackEnd ByteString Source #

A backend that stores all files in memory

tempFileBackend :: MonadResource m => m (BackEnd FilePath) Source #

A backend that stores files in a temp directory.