summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Lehnardt <jan@apache.org>2014-11-14 12:19:25 +0100
committerJan Lehnardt <jan@apache.org>2014-11-14 12:19:25 +0100
commit14e0374429b654e0779e7c0c7dd739289728e682 (patch)
tree2e708169d5627a2ed93a83edfc1d81cf1afcc275
parent3304add80963e265b80a342f650d4bb526a6c755 (diff)
downloadcouchdb-14e0374429b654e0779e7c0c7dd739289728e682.tar.gz
handle GET cluster state
-rw-r--r--src/setup.erl2
-rw-r--r--src/setup_httpd.erl12
2 files changed, 12 insertions, 2 deletions
diff --git a/src/setup.erl b/src/setup.erl
index 637468510..29576b2fa 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").
diff --git a/src/setup_httpd.erl b/src/setup_httpd.erl
index 755b95100..bdb33123d 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