summaryrefslogtreecommitdiff
path: root/src/couchdb/couch_httpd.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/couchdb/couch_httpd.erl')
-rw-r--r--src/couchdb/couch_httpd.erl24
1 files changed, 22 insertions, 2 deletions
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 = [