diff options
author | Benoit Chesneau <benoitc@apache.org> | 2010-02-02 12:12:46 +0000 |
---|---|---|
committer | Benoit Chesneau <benoitc@apache.org> | 2010-02-02 12:12:46 +0000 |
commit | 2fcfa641f6572368f60a260bfd6c8bf11a5d5b20 (patch) | |
tree | 2165f652161cf5530ed9c6d77aa0606dfe617d88 /src/couchdb/couch_httpd_rewrite.erl | |
parent | 1ba1a72eba6b02e4b499d903991423a76f52ad0d (diff) |
would have been strange to be abble ../../_changes and not
../../../_uuids in rewriting. Instead using
couch_httpd_db:handle_request we now use couch_httpd:handle_request. Add
one more unitest to test it.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@905599 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_httpd_rewrite.erl')
-rw-r--r-- | src/couchdb/couch_httpd_rewrite.erl | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/couchdb/couch_httpd_rewrite.erl b/src/couchdb/couch_httpd_rewrite.erl index 364e6c4d..eabe98df 100644 --- a/src/couchdb/couch_httpd_rewrite.erl +++ b/src/couchdb/couch_httpd_rewrite.erl @@ -159,11 +159,6 @@ handle_rewrite_req(#httpd{ % normalize final path (fix levels "." and "..") RawPath1 = ?b2l(iolist_to_binary(normalize_path(RawPath))), - - %% get path parts, needed for CouchDB dispatching - {"/" ++ NewPath2, _, _} = mochiweb_util:urlsplit_path(RawPath1), - NewPathParts1 = [?l2b(couch_httpd:unquote(Part)) - || Part <- string:tokens(NewPath2, "/")], ?LOG_DEBUG("rewrite to ~p ~n", [RawPath1]), @@ -176,11 +171,21 @@ handle_rewrite_req(#httpd{ % cleanup, It force mochiweb to reparse raw uri. MochiReq1:cleanup(), - - % send to couchdb the rewritten request - couch_httpd_db:handle_request(Req#httpd{ - path_parts=NewPathParts1, - mochi_req=MochiReq1}) + + DefaultSpec = "{couch_httpd_db, handle_request}", + DefaultFun = couch_httpd:make_arity_1_fun( + couch_config:get("httpd", "default_handler", DefaultSpec) + ), + + UrlHandlersList = lists:map( + fun({UrlKey, SpecStr}) -> + {?l2b(UrlKey), couch_httpd:make_arity_1_fun(SpecStr)} + end, couch_config:get("httpd_global_handlers")), + UrlHandlers = dict:from_list(UrlHandlersList), + + couch_httpd:handle_request(MochiReq1, DefaultFun, + UrlHandlers, Req#httpd.db_url_handlers, + Req#httpd.design_url_handlers) end. |