couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r657552 - /incubator/couchdb/trunk/src/couchdb/couch_httpd.erl
Date Sun, 18 May 2008 12:28:57 GMT
Author: jan
Date: Sun May 18 05:28:57 2008
New Revision: 657552

URL: http://svn.apache.org/viewvc?rev=657552&view=rev
Log:
- more graceful handling of unknown private URIs including more user friendly messages
- add a proper comment to the descending=false handling

Modified:
    incubator/couchdb/trunk/src/couchdb/couch_httpd.erl

Modified: incubator/couchdb/trunk/src/couchdb/couch_httpd.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/src/couchdb/couch_httpd.erl?rev=657552&r1=657551&r2=657552&view=diff
==============================================================================
--- incubator/couchdb/trunk/src/couchdb/couch_httpd.erl (original)
+++ incubator/couchdb/trunk/src/couchdb/couch_httpd.erl Sun May 18 05:28:57 2008
@@ -96,6 +96,8 @@
             {ok, Req:respond({301, [{"Location", "/_utils/"}], <<>>})};
         "/_utils/" ++ PathInfo ->
             {ok, Req:serve_file(PathInfo, DocumentRoot)};
+        "/_" ++ UnknownPrivatePath ->
+            handle_unkown_private_uri_request(Req, Method, UnknownPrivatePath);
         _Else ->
             handle_db_request(Req, Method, {Path})
     end.
@@ -129,6 +131,19 @@
 handle_replicate_request(_Req, _Method) ->
     throw({method_not_allowed, "POST"}).
 
+handle_unkown_private_uri_request(Req, _Method, UnknownPrivatePath) ->    
+  KnownPrivatePaths = ["_utils"],
+  Msg = {obj, 
+    [
+      {error, "Sorry, we could not find the private path '_" ++ 
+        mochiweb_util:unquote(UnknownPrivatePath) ++ 
+        "' you are looking for. We only know about the following path(s): '" ++ 
+        lists:flatten(KnownPrivatePaths) ++ "'"}
+    ]
+  },
+  io:format("Debug: ~p~n", [Msg]),
+  send_error(Req, 404, Msg).
+  
 % Database request handlers
 
 handle_db_request(Req, Method, {Path}) ->
@@ -631,7 +646,10 @@
                 Args %already reversed
             end;
         {"descending", "false"} ->
-          % ignore
+          % The descending=false behaviour is the default behaviour, so we
+          % simpply ignore it. This is only for convenience when playing with
+          % the HTTP API, so that a user doesn't get served an error when 
+          % flipping true to false in the descending option.
           Args;
         {"skip", Value} ->
             case (catch list_to_integer(Value)) of



Mime
View raw message