couch-simple-0.0.1.0: A modern, lightweight, complete client for CouchDB

CopyrightCopyright (c) 2015, Michael Alan Dorman
LicenseMIT
Maintainermdorman@jaunder.io
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Database.Couch.ResponseParser

Contents

Description

These relatively simple combinators can do simple extractions of data from the data returned by Database.Couch.External routines, as well as checking certain information about the actual response values.

Synopsis

Our primary interface

standardParse :: FromJSON a => ResponseParser a Source

Check the status code for a successful value and tries to decode to the user's desired type if so

Lower-level interfaces

type ResponseParser = ExceptT Error (Reader (ResponseHeaders, Status, Value)) Source

A type synonym for the Monad we're operating in

runParse :: ResponseParser a -> Either Error (ResponseHeaders, Status, Value) -> Either Error a Source

Run a given parser over an initial value

responseStatus :: ResponseParser Status Source

Extract the response status from the Monad

responseHeaders :: ResponseParser ResponseHeaders Source

Extract the response headers from the Monad

responseValue :: ResponseParser Value Source

Extract the response value from the Monad

checkStatusCode :: ResponseParser () Source

Check the status code for the response

maybeGetHeader :: HeaderName -> ResponseParser (Maybe ByteString) Source

Try to retrieve a header from the response

getHeader :: HeaderName -> ResponseParser ByteString Source

Retrieve a header from the response, or return an error if it's not present

getContentLength :: ResponseParser Integer Source

Decode the Content-Length header from the response, or return an error if it's not present

getDocRev :: ResponseParser DocRev Source

Get the document revision (ETag header), or return an error if it's not present

getKey :: Text -> ResponseParser Value Source

Get the value of a particular key from the response value, or return an error if it's not found

toOutputType :: FromJSON a => Value -> ResponseParser a Source

Decode the response value to a particular type, or return an error if it can't be decoded