Return-Path: Delivered-To: apmail-incubator-couchdb-commits-archive@locus.apache.org Received: (qmail 6032 invoked from network); 31 Aug 2008 09:53:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 31 Aug 2008 09:53:09 -0000 Received: (qmail 36027 invoked by uid 500); 31 Aug 2008 09:53:07 -0000 Delivered-To: apmail-incubator-couchdb-commits-archive@incubator.apache.org Received: (qmail 36003 invoked by uid 500); 31 Aug 2008 09:53:07 -0000 Mailing-List: contact couchdb-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: couchdb-dev@incubator.apache.org Delivered-To: mailing list couchdb-commits@incubator.apache.org Received: (qmail 35994 invoked by uid 99); 31 Aug 2008 09:53:07 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 31 Aug 2008 02:53:07 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 31 Aug 2008 09:52:17 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 6DD82238896B; Sun, 31 Aug 2008 02:52:48 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r690670 - /incubator/couchdb/trunk/src/couchdb/couch_httpd.erl Date: Sun, 31 Aug 2008 09:52:48 -0000 To: couchdb-commits@incubator.apache.org From: cmlenz@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080831095248.6DD82238896B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: cmlenz Date: Sun Aug 31 02:52:47 2008 New Revision: 690670 URL: http://svn.apache.org/viewvc?rev=690670&view=rev Log: Fix the config HTTP API for the changed JSON representation, remove the POST handling for setting option values (leaving only PUT), and add a GET /_config/section handler that allows enumerating the options in a section. Modified: incubator/couchdb/trunk/src/couchdb/couch_httpd.erl Modified: incubator/couchdb/trunk/src/couchdb/couch_httpd.erl URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/src/couchdb/couch_httpd.erl?rev=690670&r1=690669&r2=690670&view=diff ============================================================================== --- incubator/couchdb/trunk/src/couchdb/couch_httpd.erl (original) +++ incubator/couchdb/trunk/src/couchdb/couch_httpd.erl Sun Aug 31 02:52:47 2008 @@ -787,24 +787,32 @@ % Config request handlers handle_config_request(_Req, Method, {config, Config}) -> - [Section, Option] = string:tokens(Config, "/"), - handle_config_request(_Req, Method, {[Section, Option]}); + Parts = string:tokens(Config, "/"), + handle_config_request(_Req, Method, {Parts}); -% PUT /_config/Section/Option -% "value" -handle_config_request(_Req, 'PUT', {[Section, Option]}) -> - handle_config_request(_Req, 'POST', {[Section, Option]}); +% GET /_config/Section +handle_config_request(Req, 'GET', {[Section]}) -> + Options = [ + {[{name, list_to_binary(Option)}, {value, list_to_binary(Value)}]} || + {Option, Value} <- + couch_config:lookup_match({{Section, '$1'}, '$2'}, []) + ], + send_json(Req, 200, {[ + {ok, true}, + {section, list_to_binary(Section)}, + {options, Options} + ]}); -% POST,PUT /_config/Section/Option +% PUT /_config/Section/Option % "value" -handle_config_request(Req, 'POST', {[Section, Option]}) -> +handle_config_request(Req, 'PUT', {[Section, Option]}) -> Value = binary_to_list(Req:recv_body()), ok = couch_config:store({Section, Option}, Value), - send_json(Req, 200, {obj, [ + send_json(Req, 200, {[ {ok, true}, - {section, Section}, - {name, Option}, - {value, Value} + {section, list_to_binary(Section)}, + {name, list_to_binary(Option)}, + {value, list_to_binary(Value)} ]}); % GET /_config/Section/Option @@ -813,11 +821,11 @@ null -> throw({not_found, unknown_config_value}); Value -> - send_json(Req, 200, {obj, [ + send_json(Req, 200, {[ {ok, true}, - {section, Section}, - {name, Option}, - {value, Value} + {section, list_to_binary(Section)}, + {name, list_to_binary(Option)}, + {value, list_to_binary(Value)} ]}) end; @@ -828,11 +836,11 @@ throw({not_found, unknown_config_value}); OldValue -> couch_config:unset({Section, Option}), - send_json(Req, 200, {obj, [ + send_json(Req, 200, {[ {ok, true}, - {section, Section}, - {name, Option}, - {old_value, OldValue} + {section, list_to_binary(Section)}, + {name, list_to_binary(Option)}, + {value, list_to_binary(OldValue)} ]}) end.