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

Safe HaskellSafe-Infered

Database.CouchDB.Conduit.LowLevel

Contents

Description

Low-level method and tools of accessing CouchDB.

Synopsis

Response

Low-level access

couchSource

Arguments

:: MonadCouch m 
=> Method

Method

-> Path

Correct Path with escaped fragments. couchPrefix will be prepended to path.

-> RequestHeaders

Headers

-> Query

Query args

-> RequestBody m

Request body

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

Protect function. See protect

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

couch'Source

Arguments

:: MonadCouch m 
=> Method

Method

-> (Path -> Path)

couchPrefix->Path function. Output must be correct Path with escaped fragments.

-> RequestHeaders

Headers

-> Query

Query args

-> RequestBody m

Request body

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

Protect function. See protect

-> m (CouchResponse m) 

More generalized version of couch. Instead Path it takes function what takes prefix and returns a path.

Response protection

protectSource

Arguments

:: MonadCouch m 
=> [Int]

Good codes

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

handler

-> CouchResponse m

Response

-> 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

-> m (CouchResponse m) 

Protect from typical status codes. It's equivalent of

 protect [200, 201, 202, 304] return

See protect for details.