summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDamien F. Katz <damien@apache.org>2008-08-08 21:06:29 +0000
committerDamien F. Katz <damien@apache.org>2008-08-08 21:06:29 +0000
commitf2275fd25463764ea059b32ffb689baeeebc1ca1 (patch)
treea97ae4f116446f617f2b9339762dbb5b5bee7dee /src
parenta33cf09319d0b174ec9c509c815da160b7091ab3 (diff)
Idempotent document creation support, new HTTP api to generate UUIDs and support in the couch.js library for using them. Creating uuids client side ensure that document creation happens only once, despite automatic network retries.
git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@684092 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/couchdb/couch_httpd.erl13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl
index 85fbe868..7b926019 100644
--- a/src/couchdb/couch_httpd.erl
+++ b/src/couchdb/couch_httpd.erl
@@ -97,6 +97,8 @@ handle_request0(Req, DocumentRoot, Method, Path) ->
handle_replicate_request(Req, Method);
"/_restart" ->
handle_restart_request(Req, Method);
+ "/_uuids" ->
+ handle_uuids_request(Req, Method);
"/_utils" ->
{ok, Req:respond({301, [
{"Location", "/_utils/"}
@@ -148,6 +150,17 @@ handle_restart_request(Req, 'POST') ->
handle_restart_request(_Req, _Method) ->
throw({method_not_allowed, "POST"}).
+handle_uuids_request(Req, 'POST') ->
+ Count = list_to_integer(proplists:get_value("count", Req:parse_qs(), "1")),
+ % generate the uuids
+ UUIDs = [ couch_util:new_uuid() || _ <- lists:seq(1,Count)],
+ % send a JSON response
+ send_json(Req, {obj, [{"uuids", list_to_tuple(UUIDs)}]});
+
+handle_uuids_request(_Req, _Method) ->
+ throw({method_not_allowed, "POST"}).
+
+
% Database request handlers
handle_db_request(Req, Method, {Path}) ->