summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Joseph Davis <davisp@apache.org>2009-05-19 00:51:52 +0000
committerPaul Joseph Davis <davisp@apache.org>2009-05-19 00:51:52 +0000
commitc5e00c4188afd73c03bd7462ac2cc2d82387c5a6 (patch)
tree8b81059b9c9bd667db8e3771f3019aa11ce1613c
parentda50be8a9b46b69e0ed9a9d5182be37cf54ed21c (diff)
Add a configuration parameter for the default database handler.
Closes COUCHDB-353 Thanks Brad Anderson git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@776143 13f79535-47bb-0310-9956-ffa450edef68
-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)})