incubator-couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Davies <ja...@jasondavies.com>
Subject Re: Rewriting URLs
Date Sun, 05 Jul 2009 09:25:50 GMT
Hi Noah,

On 4 Jul 2009, at 23:21, Noah Slater wrote:

> On Sat, Jul 04, 2009 at 03:16:42PM -0700, Chris Anderson wrote:
>> Eventually this could be implemented in CouchDB itself, with a table
>> to lookup app-rewrites for various subdomains or ports. I think it's
>> important to limit what the design doc alone can do. Putting  
>> something
>> like a dictionary of app -> ddoc rewrites in config seems like the
>> right place to modify CouchDB at such a fundamental level.
>
> I didn't mean to suggest that design documents get to control the  
> parent URI
> space, as this could obviously introduce conflicts. I think a nice  
> approach, as
> Chris suggests, would be split into two levels:
>
>  * Design document level URI rewriting, but no parent URIs
>
>  * Server level configuration that rewrites arbitrary URIs
>
> Do we need these both in the same release? Not sure, but it would be  
> nice!

Just for fun, I made handle_rewrite_req so it can be configured as  
[httpd]
default_handler.  Chris envisaged a dictionary of app -> ddocs  
rewrites and
clearly this doesn't do this yet, but it works as a proof-of-concept.

Commit: http://github.com/jasondavies/couchdb/commit/f3ee881ccd13207207e13f230a83e5eddf31509a

To use:

[httpd]
default_handler = {couch_httpd_rewrite, handle_rewrite_req,  
{"test_suite_db", "rewrite_test"}}

Any suggestions for what the actual config would look like for mapping  
domains
and ports to databases and design docs?

I'm thinking something like:

[couch_httpd_rewrite]
{"jason.mydomain.com", 80, "/"} = {"mydb", "rootapp"}
{"jason.mydomain.com", 80, "/blog"} = {"mydb", "blogapp"}

I think people will probably want some kind of wildcard matching too  
though.
Anyway, it's early days still, I think at least supporting basic  
_rewrite is a
big win.

Cheers,
-- 
Jason Davies

www.jasondavies.com
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message