From dev-return-7615-apmail-couchdb-dev-archive=couchdb.apache.org@couchdb.apache.org Sat Dec 05 23:28:05 2009 Return-Path: Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: (qmail 79403 invoked from network); 5 Dec 2009 23:28:05 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 5 Dec 2009 23:28:05 -0000 Received: (qmail 86765 invoked by uid 500); 5 Dec 2009 23:28:05 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 86682 invoked by uid 500); 5 Dec 2009 23:28:04 -0000 Mailing-List: contact dev-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list dev@couchdb.apache.org Received: (qmail 86672 invoked by uid 99); 5 Dec 2009 23:28:04 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 05 Dec 2009 23:28:04 +0000 X-ASF-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of gcdcd-couchdb-2@m.gmane.org designates 80.91.229.12 as permitted sender) Received: from [80.91.229.12] (HELO lo.gmane.org) (80.91.229.12) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 05 Dec 2009 23:28:02 +0000 Received: from list by lo.gmane.org with local (Exim 4.50) id 1NH42M-0001zR-DA for dev@couchdb.apache.org; Sun, 06 Dec 2009 00:27:38 +0100 Received: from dsl-63-249-119-34.static.cruzio.com ([63.249.119.34]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 06 Dec 2009 00:27:38 +0100 Received: from rogerb by dsl-63-249-119-34.static.cruzio.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 06 Dec 2009 00:27:38 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: dev@couchdb.apache.org From: Roger Binns Subject: Re: _rewrite handler Date: Sat, 05 Dec 2009 15:27:12 -0800 Lines: 69 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: dsl-63-249-119-34.static.cruzio.com User-Agent: Thunderbird 2.0.0.23 (X11/20090817) In-Reply-To: X-Enigmail-Version: 0.95.7 Sender: news -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Benoit Chesneau wrote: > ? there is no prescribed behaviour With your current proposal behaviour is entirely determined by a Javascript function. What I am proposing is that Javascript function also be given a doc as input to do with as it pleases. There is no requirement for the doc to exist or the Javascript to pay any attention to it. > main point of _rewrite handler is to rewrite urls in a couchdb node or > even cluster not on different subnets. You missed my point. As an example a rewrite to a different show on the same server: function (req) { if (req.path ... matches ... "show/details") { if( isinternal(req) ) return "... show/details-internal"; return ".... show/details-public"; } } Now the isinternal function needs to look at the IP address and would typically have a table of internal addresses. With the current scheme that table would have to be built into the Javascript. > system to rewrite urls. Sometimes you want to rewrite depending on > http verb, other depending on auth or simply on path and there are > different need for rewriting on patch too. The current design allow > you to define your own way to do this. You could always make a > template that allows you to create your own set of rules. With your current proposal, code has to look like this: function (req) { var data={ ... a bunch of data ... }; if/return/etc looking at the req and data } What I am asking for is the ability to have it like this: function (req, doc) { if/return/etc looking at the req and data in doc } With your current proposal, changing the data used by the function requires regenerating Javascript code. If the data can (optionally) live in a document then no code generation is required nor is rewriting the design doc. I would expect developers to come up with some useful rewriters. For example maybe one that switches between production and development mode. Or maybe some sort of aliasing as you suggested. It would be nice to be able to control their behaviour by editing the contents of a regular doc rather than having to edit Javascript code and regenerating design docs. Roger -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAksa7EwACgkQmOOfHg372QRcxQCggrhGm8SYYAtGcvAyjE9YHhO1 1kcAoISIPlwFw85odHKooYcaiXsUzDut =EvTt -----END PGP SIGNATURE-----