diff options
author | Damien F. Katz <damien@apache.org> | 2008-09-11 19:26:09 +0000 |
---|---|---|
committer | Damien F. Katz <damien@apache.org> | 2008-09-11 19:26:09 +0000 |
commit | 634b1b193acc24b95326c74e615d723043516f16 (patch) | |
tree | faedbfddee34a23083b34998572ceb1501a8747f /src/couchdb/couch_httpd.erl | |
parent | 37ca97c918f4b5316e4293d8f1001bb87b8dfb0c (diff) |
Check-in of document purge functionality.
git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@694430 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_httpd.erl')
-rw-r--r-- | src/couchdb/couch_httpd.erl | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl index bdc172a3..3857f40d 100644 --- a/src/couchdb/couch_httpd.erl +++ b/src/couchdb/couch_httpd.erl @@ -310,6 +310,21 @@ handle_db_request(Req, 'POST', {_DbName, Db, [<<"_compact">>]}) -> handle_db_request(_Req, _Method, {_DbName, _Db, [<<"_compact">>]}) -> throw({method_not_allowed, "POST"}); +handle_db_request(Req, 'POST', {_DbName, Db, [<<"_purge">>]}) -> + {IdsRevs} = ?JSON_DECODE(Req:recv_body(?MAX_DOC_SIZE)), + % validate the json input + [{_Id, [_|_]=_Revs} = IdRevs || IdRevs <- IdsRevs], + + case couch_db:purge_docs(Db, IdsRevs) of + {ok, PurgeSeq, PurgedIdsRevs} -> + send_json(Req, 200, {[{<<"purge_seq">>, PurgeSeq}, {<<"purged">>, {PurgedIdsRevs}}]}); + Error -> + throw(Error) + end; + +handle_db_request(_Req, _Method, {_DbName, _Db, [<<"_purge">>]}) -> + throw({method_not_allowed, "POST"}); + % View request handlers handle_db_request(Req, 'GET', {_DbName, Db, [<<"_all_docs">>]}) -> |