rest-core-0.32: Rest API library.

Safe HaskellNone

Rest.Dictionary.Combinators

Contents

Description

Combinators for specifying the input/output dictionaries of a Handler. The combinators can be combined using (.).

Synopsis

Input dictionaries

someI :: Dict h p () o e -> Dict h p i o eSource

Open up input type for extension with custom dictionaries.

stringI :: Dict h p i o e -> Dict h p String o eSource

Allow direct usage of as input as String.

xmlTextI :: Dict h p i o e -> Dict h p Text o eSource

Allow direct usage of as input as raw Xml Text.

fileI :: Dict h p i o e -> Dict h p ByteString o eSource

Allow usage of input as file contents, represented as a ByteString.

readI :: (Info i, Read i, Show i) => Dict h p i o e -> Dict h p i o eSource

The input can be read into some instance of Read. For inspection reasons the type must also be an instance of both Info and Show.

xmlI :: (Typeable i, XmlPickler i) => Dict h p i o e -> Dict h p i o eSource

The input can be read into some instance of XmlPickler.

rawXmlI :: Dict h p i o e -> Dict h p ByteString o eSource

The input can be used as an XML ByteString.

jsonI :: (Typeable i, FromJSON i, JSONSchema i) => Dict h p i o e -> Dict h p i o eSource

The input can be read into some instance of Json.

Output dictionaries

someO :: Dict h p i () e -> Dict h p i o eSource

Open up output type for extension with custom dictionaries.

stringO :: Dict h p i () e -> Dict h p i String eSource

Allow output as plain String.

fileO :: Dict h p i o e -> Dict h p i (ByteString, String) eSource

Allow file output using a combination of the raw data and a mime type.

xmlO :: (Typeable o, XmlPickler o) => Dict h p i o e -> Dict h p i o eSource

Allow output as XML using the XmlPickler type class.

rawXmlO :: Dict h p i () e -> Dict h p i ByteString eSource

Allow output as raw XML represented as a ByteString.

jsonO :: (Typeable o, ToJSON o, JSONSchema o) => Dict h p i o e -> Dict h p i o eSource

Allow output as JSON using the Json type class.

multipartO :: Dict h p i () e -> Dict h p i [BodyPart] eSource

Allow output as multipart. Writes out the ByteStrings separated by boundaries, with content type 'multipart/mixed'.

Error dictionaries

someE :: (Typeable e, ToJSON e, JSONSchema e) => Dict h p i o () -> Dict h p i o eSource

Open up error type for extension with custom dictionaries.

jsonE :: (Typeable e, ToJSON e, JSONSchema e) => Dict h p i o e -> Dict h p i o eSource

Allow error output as JSON using the Json type class.

xmlE :: (Typeable e, XmlPickler e) => Dict h p i o e -> Dict h p i o eSource

Allow error output as XML using the XmlPickler type class.

Composed dictionaries

xmlJsonI :: (Typeable i, FromJSON i, JSONSchema i, XmlPickler i) => Dict h p () o e -> Dict h p i o eSource

The input can be read into some instance of both Json and XmlPickler.

xmlJsonO :: (Typeable o, ToJSON o, JSONSchema o, XmlPickler o) => Dict h p i () e -> Dict h p i o eSource

Allow output as JSON using the Json type class and allow output as XML using the XmlPickler type class.

xmlJsonE :: (Typeable e, ToJSON e, JSONSchema e, XmlPickler e) => Dict h p i o () -> Dict h p i o eSource

Allow error output as JSON using the Json type class and allow output as XML using the XmlPickler type class.

xmlJson :: (Typeable i, FromJSON i, JSONSchema i, XmlPickler i, Typeable o, ToJSON o, JSONSchema o, XmlPickler o) => Dict h p () () e -> Dict h p i o eSource

The input can be read into some instance of both Json and XmlPickler and allow output as JSON using the Json type class and allow output as XML using the XmlPickler type class.

Header dictionaries

mkHeader :: Header h -> Dict x p i o e -> Dict h p i o eSource

Set custom sub-dictionary for recognizing headers.

addHeader :: Header h -> Dict h' p i o e -> Dict (h, h') p i o eSource

Add custom sub-dictionary for recognizing headers.

Parameter dictionaries

mkPar :: Param p -> Dict h x i o e -> Dict h p i o eSource

Set custom sub-dictionary for recognizing parameters.

addPar :: Param p -> Dict h p' i o e -> Dict h (p, p') i o eSource

Add custom sub-dictionary for recognizing parameters.