couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r644656 - /incubator/couchdb/branches/mochiweb/src/couchdb/couch_httpd.erl
Date Fri, 04 Apr 2008 09:41:52 GMT
Author: jan
Date: Fri Apr  4 02:41:50 2008
New Revision: 644656

URL: http://svn.apache.org/viewvc?rev=644656&view=rev
Log:
Refactor fulltext HTTP API handling: Less code, more pattern matching.

Modified:
    incubator/couchdb/branches/mochiweb/src/couchdb/couch_httpd.erl

Modified: incubator/couchdb/branches/mochiweb/src/couchdb/couch_httpd.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/mochiweb/src/couchdb/couch_httpd.erl?rev=644656&r1=644655&r2=644656&view=diff
==============================================================================
--- incubator/couchdb/branches/mochiweb/src/couchdb/couch_httpd.erl (original)
+++ incubator/couchdb/branches/mochiweb/src/couchdb/couch_httpd.erl Fri Apr  4 02:41:50 2008
@@ -122,21 +122,13 @@
 handle_replicate_request(_Req, _Method) ->
     throw({method_not_allowed, "POST"}).
 
-
 % Database request handlers
 
 handle_db_request(Req, Method, {Path}) ->
     UriParts = string:tokens(Path, "/"),
     [DbName|Rest] = UriParts,
-    UnquotedDbName = mochiweb_util:unquote(DbName),
-    case Rest of
-        ["_fulltext"|_] ->
-            handle_db_fulltext_request(Req, Method, UnquotedDbName);
-        _ ->
-            handle_db_request(Req, Method, {UnquotedDbName, Rest})
-    end;
+    handle_db_request(Req, Method, {mochiweb_util:unquote(DbName), Rest});
     
-
 handle_db_request(Req, 'PUT', {DbName, []}) ->
     case couch_server:create(DbName, []) of
         {ok, _Db} ->
@@ -231,6 +223,15 @@
 handle_db_request(_Req, _Method, {_DbName, _Db, ["_bulk_docs"]}) ->
     throw({method_not_allowed, "POST"});
 
+handle_db_request(Req, Method, {DbName, Db, ["_fulltext"]}) ->
+    case Req:parse_qs() of 
+        [{"q", Query}] ->
+            {ok, Response} = couch_ft_query:execute(DbName, Query),
+            send_json(Req, {obj, [{ok, true} | Response]});
+        _Error ->
+            throw({no_fulltext_query, "Empty Query String"})
+    end;
+
 % View request handlers
 
 handle_db_request(Req, 'GET', {_DbName, Db, ["_all_docs"]}) ->
@@ -371,15 +372,6 @@
 handle_db_request(Req, Method, {DbName, Db, [Resource]}) ->
     DocId = mochiweb_util:unquote(Resource),
     handle_doc_request(Req, Method, DbName, Db, DocId).
-
-handle_db_fulltext_request(Req, Method, UnquotedDbName) ->
-    case Req:parse_qs() of 
-        [{"q", Query}] ->
-            {ok, Response} = couch_ft_query:execute(UnquotedDbName, Query),
-            send_json(Req, {obj, [{ok, true} | Response]});
-        _Error ->
-            throw({no_fulltext_query, "Empty Query String"})
-    end.
 
 handle_doc_request(Req, 'DELETE', _DbName, Db, DocId) ->
     % TODO: Etag handling



Mime
View raw message