Add POST /_node/<node>/_config/_reload
Using the backend port 5986 it was possible to reload config from disk
using the _config/_reload endpoint. This ports it to the _node API
on the frontend cluster port.
diff --git a/src/chttpd/src/chttpd_node.erl b/src/chttpd/src/chttpd_node.erl
index 2020702..acd5aff 100644
--- a/src/chttpd/src/chttpd_node.erl
+++ b/src/chttpd/src/chttpd_node.erl
@@ -46,6 +46,16 @@
send_json(Req, 200, {KVs});
handle_node_req(#httpd{path_parts=[_, _Node, <<"_config">>]}=Req) ->
send_method_not_allowed(Req, "GET");
+% POST /_node/$node/_config/_reload - Flushes unpersisted config values from RAM
+handle_node_req(#httpd{method='POST', path_parts=[_, Node, <<"_config">>, <<"_reload">>]}=Req) ->
+ case call_node(Node, config, reload, []) of
+ ok ->
+ send_json(Req, 200, {[{ok, true}]});
+ {error, Reason} ->
+ chttpd:send_error(Req, {bad_request, Reason})
+ end;
+handle_node_req(#httpd{path_parts=[_, _Node, <<"_config">>, <<"_reload">>]}=Req) ->
+ send_method_not_allowed(Req, "POST");
% GET /_node/$node/_config/Section
handle_node_req(#httpd{method='GET', path_parts=[_, Node, <<"_config">>, Section]}=Req) ->
KVs = [{list_to_binary(Key), list_to_binary(Value)}
diff --git a/test/elixir/test/config_test.exs b/test/elixir/test/config_test.exs
index 2b2d714..53c5bc8 100644
--- a/test/elixir/test/config_test.exs
+++ b/test/elixir/test/config_test.exs
@@ -174,4 +174,11 @@
set_config(context, section, "wohali", "rules", 403)
end)
end
+
+ test "Reload config", context do
+ url = "#{context[:config_url]}/_reload"
+ resp = Couch.post(url)
+
+ assert resp.status_code == 200
+ end
end