rest-core-0.39: Rest API library.

Safe HaskellNone
LanguageHaskell98

Rest.Dictionary.Combinators

Contents

Description

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

Synopsis

Input dictionaries

stringI :: Dict h p Nothing o e -> Dict h p (Just String) o e Source #

Allow direct usage of as input as String.

xmlTextI :: Dict h p Nothing o e -> Dict h p (Just Text) o e Source #

Allow direct usage of as input as raw Xml Text.

fileI :: Dict h p Nothing o e -> Dict h p (Just ByteString) o e Source #

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

readI :: (Info i, Read i, Show i, FromMaybe i i' ~ i) => Dict h p i' o e -> Dict h p (Just i) o e Source #

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, FromMaybe i i' ~ i) => Dict h p i' o e -> Dict h p (Just i) o e Source #

The input can be read into some instance of XmlPickler.

rawXmlI :: Dict h p Nothing o e -> Dict h p (Just ByteString) o e Source #

The input can be used as an XML ByteString.

jsonI :: (Typeable i, FromJSON i, JSONSchema i, FromMaybe i i' ~ i) => Dict h p i' o e -> Dict h p (Just i) o e Source #

The input can be read into some instance of Json.

rawJsonI :: Dict h p Nothing o e -> Dict h p (Just ByteString) o e Source #

The input can be used as a JSON ByteString.

rawJsonAndXmlI :: Dict h p Nothing o e -> Dict h p (Just (Either Json Xml)) o e Source #

The input can be used as a JSON or XML ByteString.

An API client can send either format so the handler needs to handle both.

Output dictionaries

stringO :: Dict h p i Nothing e -> Dict h p i (Just String) e Source #

Allow output as plain String.

fileO :: Dict h p i Nothing e -> Dict h p i (Just (ByteString, String, Bool)) e Source #

Allow file output using a combination of the raw data, the file name, and an attachment flag (causing the file to be downloaded by browsers instead of shown). The mime type will be determined from the file extension by your web server library, or "application/octet-stream" with an unknown extension.

xmlO :: (Typeable o, XmlPickler o, FromMaybe o o' ~ o) => Dict h p i o' e -> Dict h p i (Just o) e Source #

Allow output as XML using the XmlPickler type class.

rawXmlO :: Dict h p i Nothing e -> Dict h p i (Just ByteString) e Source #

Allow output as raw XML represented as a ByteString.

jsonO :: (Typeable o, ToJSON o, JSONSchema o, FromMaybe o o' ~ o) => Dict h p i o' e -> Dict h p i (Just o) e Source #

Allow output as JSON using the Json type class.

rawJsonO :: Dict h p i Nothing e -> Dict h p i (Just ByteString) e Source #

Allow output as raw JSON represented as a ByteString.

rawJsonAndXmlO :: Dict h p i Nothing e -> Dict h p i (Just ByteString) e Source #

Allow output as raw JSON and XML represented as ByteStrings. Both values are needed since the accept header determines which one to send.

multipartO :: Dict h p i Nothing e -> Dict h p i (Just [BodyPart]) e Source #

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

Error dictionaries

jsonE :: (ToResponseCode e, Typeable e, ToJSON e, JSONSchema e, FromMaybe e e' ~ e) => Dict h p i o e' -> Dict h p i o (Just e) Source #

Allow error output as JSON using the Json type class.

xmlE :: (ToResponseCode e, Typeable e, XmlPickler e, FromMaybe e e' ~ e) => Dict h p i o e' -> Dict h p i o (Just e) Source #

Allow error output as XML using the XmlPickler type class.

Composed dictionaries

xmlJsonI :: (Typeable i, FromJSON i, JSONSchema i, XmlPickler i, FromMaybe i i' ~ i) => Dict h p i' o e -> Dict h p (Just i) o e Source #

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

xmlJsonO :: (Typeable o, ToJSON o, JSONSchema o, XmlPickler o, FromMaybe o o' ~ o) => Dict h p i o' e -> Dict h p i (Just o) e Source #

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

xmlJsonE :: (ToResponseCode e, Typeable e, ToJSON e, JSONSchema e, XmlPickler e, FromMaybe e e' ~ e) => Dict h p i o e' -> Dict h p i o (Just e) Source #

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, FromMaybe i i' ~ i, FromMaybe o o' ~ o) => Dict h p i' o' e -> Dict h p (Just i) (Just o) e Source #

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 e Source #

Set custom sub-dictionary for recognizing headers.

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

Add custom sub-dictionary for recognizing headers.

Parameter dictionaries

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

Set custom sub-dictionary for recognizing parameters.

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

Add custom sub-dictionary for recognizing parameters.

Deprecated

someI :: Dict h p i o e -> Dict h p i o e Source #

Deprecated: This can be safely removed, it is now just the identity.

Open up input type for extension with custom dictionaries.

someO :: Dict h p i o e -> Dict h p i o e Source #

Deprecated: This can be safely removed, it is now just the identity.

Open up output type for extension with custom dictionaries.

someE :: Dict h p i o e -> Dict h p i o e Source #

Deprecated: This can be safely removed, it is now just the identity.

Open up error type for extension with custom dictionaries.