summaryrefslogtreecommitdiff
path: root/src/couchdb/couch_httpd_misc_handlers.erl
diff options
context:
space:
mode:
authorJohn Christopher Anderson <jchris@apache.org>2008-10-10 02:23:11 +0000
committerJohn Christopher Anderson <jchris@apache.org>2008-10-10 02:23:11 +0000
commit6b5676f0929b5f5da3e37e985484494bf3675b94 (patch)
treee63aea190560882e4ce7833bc1a2979ae37be35d /src/couchdb/couch_httpd_misc_handlers.erl
parent074180cff70b4687bb9619a76987ced7e711d1c5 (diff)
config web service fix from davisp
git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@703315 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_httpd_misc_handlers.erl')
-rw-r--r--src/couchdb/couch_httpd_misc_handlers.erl13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/couchdb/couch_httpd_misc_handlers.erl b/src/couchdb/couch_httpd_misc_handlers.erl
index 040e34de..8372c1b5 100644
--- a/src/couchdb/couch_httpd_misc_handlers.erl
+++ b/src/couchdb/couch_httpd_misc_handlers.erl
@@ -93,8 +93,17 @@ handle_uuids_req(Req) ->
% GET /_config/
% GET /_config
handle_config_req(#httpd{method='GET', path_parts=[_]}=Req) ->
- KVs = [{list_to_binary(Key), list_to_binary(Value)}
- || {Key, Value} <- couch_config:all()],
+ Grouped = lists:foldl(fun({{Section, Key}, Value}, Acc) ->
+ case dict:is_key(Section, Acc) of
+ true ->
+ dict:append(Section, {list_to_binary(Key), list_to_binary(Value)}, Acc);
+ false ->
+ dict:store(Section, [{list_to_binary(Key), list_to_binary(Value)}], Acc)
+ end
+ end, dict:new(), couch_config:all()),
+ KVs = dict:fold(fun(Section, Values, Acc) ->
+ [{list_to_binary(Section), {Values}} | Acc]
+ end, [], Grouped),
send_json(Req, 200, {KVs});
% GET /_config/Section
handle_config_req(#httpd{method='GET', path_parts=[_,Section]}=Req) ->