On Sat, Jul 4, 2009 at 3:12 PM, Paul Davis<[email protected]> wrote: > On Sat, Jul 4, 2009 at 6:08 PM, Noah Slater<[email protected]> wrote: >> Hey Jason, >> >> On Sat, Jul 04, 2009 at 10:34:27PM +0100, Jason Davies wrote: >>> The basic idea is you add a "rewrites": [...] member to your design doc. >>> This will allow rewriting of any URLs with the prefix mydb/ >>> _design/app/_rewrite. The "rewrites" member is a list of rewrite rules >>> of the form {match: ["foo/bar/<var>"], rewrite:["_view/myview", >>> {startkey: ["<var>"], endkey: ["<var>", {}]}] >> >> This is great! >> >> Don't let me contribute stop-energy, but I am thinking that if we're going >> to do >> this, we might want to go the full way an implement this from the root URI of >> the whole CouchDB server instead. >> >> Best, >> >> -- >> Noah Slater, http://tumbolia.org/nslater >> > > We've discussed where to push the URL rewriting previously. The > biggest argument against a DB wide rewrite scheme is that _design/ > documents could end up stomping on each other pretty easily. > > For reference in case other people are confused, the rewrite > capabilities would be best used by putting a proxy in front of CouchDB > that would rewrite all urls to the appropiate CouchDB path. > > Something like: > > Rewrite http://blog.mydomain.com/ to > http://127.0.0.1:5984/my_blog_db/_design/sofar/_rewrite/ >
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. Chris -- Chris Anderson http://jchrisa.net http://couch.io
