couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roger Binns <>
Subject Re: _rewrite handler
Date Sat, 05 Dec 2009 23:27:12 GMT
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.

Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla -


View raw message