summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Kocoloski <kocolosk@apache.org>2019-09-25 12:28:55 -0400
committerGitHub <noreply@github.com>2019-09-25 12:28:55 -0400
commit77f64b4f4beb1b8ee7449cf2ff73d7f162366229 (patch)
tree6be2488aa4125d4776daffd60206725ef098df04
parent7196a3c4b721158045af36e592ffdc7cc50abb3d (diff)
downloadcouchdb-77f64b4f4beb1b8ee7449cf2ff73d7f162366229.tar.gz
Include search in the list of advertised features (#2206)
The reason we don't do this in config:features() directly is because this one is a dynamic check for the presence of a connected clouseau node. Calling `enable_feature` every time we conduct that check seemed too heavyweight, but I didn't see a good opportunity to just call it once and be confident that it would reliably advertise the feature. The downside here is that CouchDB will not advertise the "search" feature if Clouseau is disconnected for maintenance or whatever, although technically it's accurate since search requests submitted during that interval would fail. Closes #2205
-rw-r--r--src/chttpd/src/chttpd_misc.erl10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/chttpd/src/chttpd_misc.erl b/src/chttpd/src/chttpd_misc.erl
index 819d7820e..17122bf85 100644
--- a/src/chttpd/src/chttpd_misc.erl
+++ b/src/chttpd/src/chttpd_misc.erl
@@ -51,7 +51,7 @@ handle_welcome_req(#httpd{method='GET'}=Req, WelcomeMessage) ->
{version, list_to_binary(couch_server:get_version())},
{git_sha, list_to_binary(couch_server:get_git_sha())},
{uuid, couch_server:get_uuid()},
- {features, config:features()}
+ {features, get_features()}
] ++ case config:get("vendor") of
[] ->
[];
@@ -62,6 +62,14 @@ handle_welcome_req(#httpd{method='GET'}=Req, WelcomeMessage) ->
handle_welcome_req(Req, _) ->
send_method_not_allowed(Req, "GET,HEAD").
+get_features() ->
+ case clouseau_rpc:connected() of
+ true ->
+ [search | config:features()];
+ false ->
+ config:features()
+ end.
+
handle_favicon_req(Req) ->
handle_favicon_req(Req, get_docroot()).