apache/couchdb — pull request #32 by bjnortier (2012-09-21 08:58:49+00:00)
Title: Document Id and Rev in response headers

This patch adds the X-Couch-Id and X-Couch-Rev headers to responses, so that a custom default_handler can act on DB changes (e.g. create tasks).

We have a custom default_handler that creates Celery tasks via a Python process. It wraps the couch_httpd_d:handle_request/1 function, looks at the response, then creates some tasks. What it needs is the document Id and Rev for each PUT/POST/DELETE request, but those are not available from the Response on that level (the response body is sent to the socket inside the black box somewhere). The headers are available. So we decided to add the Id and Rev to the JSON responses and also the update function as X-Couch-Id and X-Couch-Rev. When using an update function, the rev is available though "X-Couch-Update-NewRev", so only the Id has been added.

We have a large amount of small databases (potentially thousands), so it is not practical to listen to changes on every DB.

If there is another recommendation to achieve this without patching, please suggest an alternative.