couchdb-conduit-0.7.3: Couch DB client library using http-conduit and aeson

Safe HaskellSafe-Infered

Database.CouchDB.Conduit.LowLevel

Description

Low-level method and tools of accessing CouchDB.

Synopsis

Documentation

type CouchResponse m = Response (Source m ByteString)Source

CouchDB response

couchSource

Arguments

:: MonadCouch m 
=> Method

Method

-> Path

Correct Path with escaped fragments.

-> RequestHeaders

Headers

-> Query

Query args

-> RequestBody m

Request body

-> (CouchResponse m -> ResourceT m (CouchResponse m))

Protect function. See protect

-> ResourceT m (CouchResponse m) 

The most general method of accessing CouchDB. This is a very thin wrapper around http. Most of the time you should use one of the other access functions, but this function is needed for example to write and read attachments that are not in JSON format.

protectSource

Arguments

:: MonadCouch m 
=> [Int]

Good codes

-> (CouchResponse m -> ResourceT m (CouchResponse m))

handler

-> CouchResponse m

Response

-> ResourceT m (CouchResponse m) 

Protect Response from bad status codes. If status code in list of status codes - just return response. Otherwise - throw CouchError.

Instead checkStatus, protect parses CouchDB response body JSON and extract "reason" message.

To protect from typical errors use protect'.

protect'Source

Arguments

:: MonadCouch m 
=> CouchResponse m

Response

-> ResourceT m (CouchResponse m) 

Protect from typical status codes. It's equivalent of

 protect [200, 201, 202, 304] return

See protect for details.