couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From beno...@apache.org
Subject svn commit: r906111 - in /couchdb/trunk/src/couchdb: couch_db.hrl couch_httpd.erl couch_httpd_rewrite.erl
Date Wed, 03 Feb 2010 16:30:08 GMT
Author: benoitc
Date: Wed Feb  3 16:30:08 2010
New Revision: 906111

URL: http://svn.apache.org/viewvc?rev=906111&view=rev
Log:
add default_fun and url_handlers to #http. It's useful for any custom
handler that need to use the 
http_handler and not only the db and design http handlers. Like for
example in the rewriter.


Modified:
    couchdb/trunk/src/couchdb/couch_db.hrl
    couchdb/trunk/src/couchdb/couch_httpd.erl
    couchdb/trunk/src/couchdb/couch_httpd_rewrite.erl

Modified: couchdb/trunk/src/couchdb/couch_db.hrl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_db.hrl?rev=906111&r1=906110&r2=906111&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_db.hrl (original)
+++ couchdb/trunk/src/couchdb/couch_db.hrl Wed Feb  3 16:30:08 2010
@@ -73,7 +73,9 @@
     user_ctx,
     req_body = undefined,
     design_url_handlers,
-    auth
+    auth,
+    default_fun,
+    url_handlers
     }).
 
 

Modified: couchdb/trunk/src/couchdb/couch_httpd.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd.erl?rev=906111&r1=906110&r2=906111&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd.erl Wed Feb  3 16:30:08 2010
@@ -175,7 +175,9 @@
         path_parts = [list_to_binary(couch_httpd:unquote(Part))
                 || Part <- string:tokens(Path, "/")],
         db_url_handlers = DbUrlHandlers,
-        design_url_handlers = DesignUrlHandlers
+        design_url_handlers = DesignUrlHandlers,
+        default_fun = DefaultFun,
+        url_handlers = UrlHandlers
     },
 
     HandlerFun = couch_util:dict_find(HandlerKey, UrlHandlers, DefaultFun),

Modified: couchdb/trunk/src/couchdb/couch_httpd_rewrite.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_rewrite.erl?rev=906111&r1=906110&r2=906111&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_rewrite.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_rewrite.erl Wed Feb  3 16:30:08 2010
@@ -172,20 +172,15 @@
             % cleanup, It force mochiweb to reparse raw uri.
             MochiReq1:cleanup(),
             
-            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),
+            #httpd{
+                db_url_handlers = DbUrlHandlers,
+                design_url_handlers = DesignUrlHandlers,
+                default_fun = DefaultFun,
+                url_handlers = UrlHandlers
+            } = Req,
             
             couch_httpd:handle_request(MochiReq1, DefaultFun, 
-                    UrlHandlers, Req#httpd.db_url_handlers, 
-                    Req#httpd.design_url_handlers)
+                    UrlHandlers, DbUrlHandlers, DesignUrlHandlers)
         end.
             
 



Mime
View raw message