summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristopher Lenz <cmlenz@apache.org>2008-09-16 20:24:48 +0000
committerChristopher Lenz <cmlenz@apache.org>2008-09-16 20:24:48 +0000
commit70155ce87a85a5b70a225f350863e7ed50097345 (patch)
treec70671528ecbf4574e3718be0291ed52e5759d08 /src
parent7748f4bdc38d34b6c078693446ce638e2d0767ae (diff)
Add HTTP API for getting the complete config, and add a page to Futon that displays the configuration.
git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@696041 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/couchdb/couch_config.erl2
-rw-r--r--src/couchdb/couch_httpd.erl24
2 files changed, 23 insertions, 3 deletions
diff --git a/src/couchdb/couch_config.erl b/src/couchdb/couch_config.erl
index 6822dc5c..8bce5718 100644
--- a/src/couchdb/couch_config.erl
+++ b/src/couchdb/couch_config.erl
@@ -158,4 +158,4 @@ handle_info({'DOWN', _, _, DownPid, _}, #config{notify_funs=PidFuns}=Config) ->
terminate(_Reason, _State) -> ok.
%% @doc Unused
-code_change(_OldVersion, State, _Extra) -> {ok, State}. \ No newline at end of file
+code_change(_OldVersion, State, _Extra) -> {ok, State}.
diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl
index b30ef7ee..604e1454 100644
--- a/src/couchdb/couch_httpd.erl
+++ b/src/couchdb/couch_httpd.erl
@@ -207,10 +207,14 @@ handle_db_request(Req, 'PUT', {DbName, []}) ->
couch_db:close(Db),
send_json(Req, 201, {[{ok, true}]});
{error, database_already_exists} ->
- Msg = io_lib:format("Database ~p already exists.", [DbName]),
+ Msg = io_lib:format("Database ~p already exists.", [
+ binary_to_list(DbName)
+ ]),
throw({database_already_exists, Msg});
Error ->
- Msg = io_lib:format("Error creating database ~p: ~p", [DbName, Error]),
+ Msg = io_lib:format("Error creating database ~p: ~p", [
+ binary_to_list(DbName), Error
+ ]),
throw({unknown_error, Msg})
end;
@@ -805,6 +809,22 @@ handle_config_request(_Req, Method, {config, Config}) ->
Parts = string:tokens(Config, "/"),
handle_config_request(_Req, Method, {Parts});
+% GET /_config
+handle_config_request(Req, 'GET', {[]}) ->
+ send_json(Req, 200, {dict:to_list(dict:map(
+ fun(_, Value) -> {Value} end,
+ lists:foldl(
+ fun({{Section, Option}, Value}, Acc) ->
+ SecBin = list_to_binary(Section),
+ OptBin = list_to_binary(Option),
+ ValBin = list_to_binary(Value),
+ dict:append(SecBin, {OptBin, ValBin}, Acc)
+ end,
+ dict:new(),
+ couch_config:all()
+ )
+ ))});
+
% GET /_config/Section
handle_config_request(Req, 'GET', {[Section]}) ->
KVs = [