webapi-0.2.1.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.

data OctetStream Source

Type representing content type of application/octetstream.

data MultipartFormData Source

Type representing content type of multipart/form-data.

data UrlEncoded Source

Type representing content type of application/x-www-form-urlencoded.

Creating custom Content Types.

data Content ctypes a Source

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 

class PartEncodings xs where Source

Methods

partEncodings :: Proxy xs -> HListToRecTuple (StripContents xs) -> [[(MediaType, Builder)]] Source

Instances

PartEncodings ([] *) Source 
(PartEncodings ts, Encodings ctypes (StripContent t), (~) * (MkContent t) (Content ctypes a)) => PartEncodings ((:) * t ts) Source 

class PartDecodings xs where Source

Methods

partDecodings :: Proxy xs -> [(ByteString, ByteString)] -> Either String (HListToRecTuple (StripContents xs)) Source

Instances

PartDecodings ([] *) Source 
(PartDecodings ts, Decodings ctypes (StripContent t), (~) * (MkContent t) (Content ctypes a)) => PartDecodings ((:) * t ts) Source 

type family StripContents a :: [*] Source

Equations

StripContents (t : ts) = StripContent t : StripContents ts 
StripContents `[]` = `[]`