webapi-0.2.0.0: WAI based library for web api

LicenseBSD3
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

WebApi.ContentTypes

Contents

Description

 

Synopsis

Predefined Content Types.

data JSON Source

Type representing content type of application/json.

data PlainText Source

Type representing content type of text/plain.

Creating custom Content Types.

class Accept ctype where Source

Singleton class for content type.

Methods

contentType :: Proxy ctype -> MediaType Source

class Accept a => Encode a c where Source

Encode a type into a specific content type.

Methods

encode :: Proxy a -> c -> Builder Source

Instances

class Accept c => Decode c a where Source

(Try to) Decode a type from a specific content type.

Converting from and to Text

class FromText a where Source

Methods

fromText :: Text -> Maybe a Source

Instances

class ToText a where Source

Methods

toText :: a -> Text Source

Instances

Internal classes.

class Encodings ctypes a where Source

Encodings of type for all content types ctypes.

Methods

encodings :: Proxy ctypes -> a -> [(MediaType, Builder)] Source

Instances

Encodings ([] *) a Source 
(Accept ctype, Encode ctype a, Encodings ctypes a) => Encodings ((:) * ctype ctypes) a Source 

class Decodings ctypes a where Source

Decodings of type for all content types ctypes.

Methods

decodings :: Proxy ctypes -> ByteString -> [(MediaType, Either String a)] Source

Instances

Decodings ([] *) a Source 
(Accept ctype, Decode ctype a, Decodings ctypes a) => Decodings ((:) * ctype ctypes) a Source