summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
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 = [