Safe Haskell | Safe-Infered |
---|
Low-level method and tools of accessing CouchDB.
- type CouchResponse m = Response (ResumableSource m ByteString)
- couch :: MonadCouch m => Method -> Path -> RequestHeaders -> Query -> RequestBody m -> (CouchResponse m -> m (CouchResponse m)) -> m (CouchResponse m)
- couch' :: MonadCouch m => Method -> (Path -> Path) -> RequestHeaders -> Query -> RequestBody m -> (CouchResponse m -> m (CouchResponse m)) -> m (CouchResponse m)
- protect :: MonadCouch m => [Int] -> (CouchResponse m -> m (CouchResponse m)) -> CouchResponse m -> m (CouchResponse m)
- protect' :: MonadCouch m => CouchResponse m -> m (CouchResponse m)
Response
type CouchResponse m = Response (ResumableSource m ByteString)Source
CouchDB response
Low-level access
:: MonadCouch m | |
=> Method | Method |
-> Path | Correct |
-> RequestHeaders | Headers |
-> Query | Query args |
-> RequestBody m | Request body |
-> (CouchResponse m -> m (CouchResponse m)) | Protect function. See |
-> 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.
:: MonadCouch m | |
=> Method | Method |
-> (Path -> Path) |
|
-> RequestHeaders | Headers |
-> Query | Query args |
-> RequestBody m | Request body |
-> (CouchResponse m -> m (CouchResponse m)) | Protect function. See |
-> m (CouchResponse m) |
Response protection
:: 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'
.
:: 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.