Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 31989C799 for ; Fri, 14 Nov 2014 11:19:37 +0000 (UTC) Received: (qmail 67057 invoked by uid 500); 14 Nov 2014 11:19:37 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 67007 invoked by uid 500); 14 Nov 2014 11:19:37 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 66998 invoked by uid 99); 14 Nov 2014 11:19:37 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 14 Nov 2014 11:19:37 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id BCAA294045B; Fri, 14 Nov 2014 11:19:36 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jan@apache.org To: commits@couchdb.apache.org Message-Id: <526791262b664ec49919e1eec159651d@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: couchdb-setup git commit: handle GET cluster state Date: Fri, 14 Nov 2014 11:19:36 +0000 (UTC) Repository: couchdb-setup Updated Branches: refs/heads/master 3304add80 -> 14e037442 handle GET cluster state Project: http://git-wip-us.apache.org/repos/asf/couchdb-setup/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-setup/commit/14e03744 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-setup/tree/14e03744 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-setup/diff/14e03744 Branch: refs/heads/master Commit: 14e0374429b654e0779e7c0c7dd739289728e682 Parents: 3304add Author: Jan Lehnardt Authored: Fri Nov 14 12:19:25 2014 +0100 Committer: Jan Lehnardt Committed: Fri Nov 14 12:19:25 2014 +0100 ---------------------------------------------------------------------- src/setup.erl | 2 ++ src/setup_httpd.erl | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-setup/blob/14e03744/src/setup.erl ---------------------------------------------------------------------- diff --git a/src/setup.erl b/src/setup.erl index 6374685..29576b2 100644 --- a/src/setup.erl +++ b/src/setup.erl @@ -13,6 +13,8 @@ -module(setup). -export([enable_cluster/1, finish_cluster/0, add_node/1, receive_cookie/1]). +-export([is_cluster_enabled/0]). + -include_lib("../couch/include/couch_db.hrl"). http://git-wip-us.apache.org/repos/asf/couchdb-setup/blob/14e03744/src/setup_httpd.erl ---------------------------------------------------------------------- diff --git a/src/setup_httpd.erl b/src/setup_httpd.erl index 755b951..bdb3312 100644 --- a/src/setup_httpd.erl +++ b/src/setup_httpd.erl @@ -11,10 +11,11 @@ % the License. -module(setup_httpd). +-include_lib("couch/include/couch_db.hrl"). -export([handle_setup_req/1]). -handle_setup_req(Req) -> +handle_setup_req(#httpd{method='POST'}=Req) -> ok = chttpd:verify_is_server_admin(Req), couch_httpd:validate_ctype(Req, "application/json"), Setup = get_body(Req), @@ -25,9 +26,16 @@ handle_setup_req(Req) -> chttpd:send_json(Req, 201, {[{ok, true}]}); {error, Message} -> couch_httpd:send_error(Req, 400, <<"bad_request">>, Message) + end; +handle_setup_req(#httpd{method='GET'}=Req) -> + ok = chttpd:verify_is_server_admin(Req), + case setup:is_cluster_enabled() of + no -> + chttpd:send_json(Req, 201, {[{state, cluster_disabled}]}); + ok -> + chttpd:send_json(Req, 201, {[{state, cluster_enabled}]}) end. - get_options(Options, Setup) -> ExtractValues = fun({Tag, Option}, OptionsAcc) -> case couch_util:get_value(Option, Setup) of