From 36bbc72b6b0992639a0ba7a2077d75ec9f7cf03d Mon Sep 17 00:00:00 2001 From: John Christopher Anderson Date: Tue, 11 Aug 2009 18:50:08 +0000 Subject: Initial commit of _update handler. Thanks to Paul Davis, Jason Davies for code and others for discussion. The _update handler accepts POSTs to paths like: /db/_design/foo/_update/bar and PUTs which include docids, like: /db/_design/foo/_update/bar/docid The function signature: function(doc, req) { doc.a_new_field = req.query.something; return [doc, "

added something to your doc

"]; } The tests in update_documents.js are fairly complete and include examples of bumping a counter, changing only a single field, parsing from (and returning) XML, and creating new documents. git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@803245 13f79535-47bb-0310-9956-ffa450edef68 --- src/couchdb/couch_httpd_external.erl | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/couchdb/couch_httpd_external.erl') diff --git a/src/couchdb/couch_httpd_external.erl b/src/couchdb/couch_httpd_external.erl index d6fa945f..0a222311 100644 --- a/src/couchdb/couch_httpd_external.erl +++ b/src/couchdb/couch_httpd_external.erl @@ -57,8 +57,7 @@ process_external_req(HttpReq, Db, Name) -> json_req_obj(#httpd{mochi_req=Req, method=Verb, path_parts=Path, - req_body=ReqBody, - user_ctx=#user_ctx{name=UserName, roles=UserRoles} + req_body=ReqBody }, Db) -> Body = case ReqBody of undefined -> Req:recv_body(); @@ -70,7 +69,6 @@ json_req_obj(#httpd{mochi_req=Req, _ -> [] end, - UserCtx = {[{<<"name">>, UserName}, {<<"roles">>, UserRoles}]}, Headers = Req:get(headers), Hlist = mochiweb_headers:to_list(Headers), {ok, Info} = couch_db:get_db_info(Db), @@ -83,7 +81,7 @@ json_req_obj(#httpd{mochi_req=Req, {<<"body">>, Body}, {<<"form">>, to_json_terms(ParsedForm)}, {<<"cookie">>, to_json_terms(Req:parse_cookie())}, - {<<"userCtx">>, UserCtx}]}. + {<<"userCtx">>, couch_util:json_user_ctx(Db)}]}. to_json_terms(Data) -> to_json_terms(Data, []). -- cgit v1.2.3