summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--etc/couchdb/default.ini.tpl.in1
-rw-r--r--src/couchdb/couch_httpd.erl13
2 files changed, 12 insertions, 2 deletions
diff --git a/etc/couchdb/default.ini.tpl.in b/etc/couchdb/default.ini.tpl.in
index 02aea96b..917d1822 100644
--- a/etc/couchdb/default.ini.tpl.in
+++ b/etc/couchdb/default.ini.tpl.in
@@ -17,6 +17,7 @@ batch_save_interval = 1000 ; milliseconds after which to save batches
port = 5984
bind_address = 127.0.0.1
authentication_handler = {couch_httpd, default_authentication_handler}
+default_handler = {couch_httpd_db, handle_request}
WWW-Authenticate = Basic realm="administrator"
[log]
diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl
index 1acb6b1b..8cdc8733 100644
--- a/src/couchdb/couch_httpd.erl
+++ b/src/couchdb/couch_httpd.erl
@@ -156,10 +156,19 @@ handle_request(MochiReq, UrlHandlers, DbUrlHandlers, DesignUrlHandlers) ->
|| Part <- string:tokens(Path, "/")],
db_url_handlers = DbUrlHandlers,
design_url_handlers = DesignUrlHandlers
- },
- DefaultFun = fun couch_httpd_db:handle_request/1,
+ },
+
+ DefaultSpec = "{couch_httpd_db, handle_request}",
+ DefaultFun = make_arity_1_fun(
+ couch_config:get("httpd", "default_handler", DefaultSpec)
+ ),
HandlerFun = couch_util:dict_find(HandlerKey, UrlHandlers, DefaultFun),
+ Self = self(),
+ ok = couch_config:register(
+ fun("httpd", "default_handler") -> exit(Self, config_change) end
+ ),
+
{ok, Resp} =
try
HandlerFun(HttpReq#httpd{user_ctx=AuthenticationFun(HttpReq)})