Hi Robin, I re-read the comments on your PR. I hope you didn't read it too personally as I'm sure that wasn't the intention of those that commented. The issue is that a roundtrip through Javascript evaluation is a significant overhead. No matter how you implemented it, it would almost certainly be too slow for a useful URL rewriting feature. I don't dispute that the URL rewriter in couchdb could be improved, though. I think a viable path would be a more powerful microlanguage, something modelled on mod_rewrite or the nginx module, perhaps? In summary, I'd love to see a rewriter feature in CouchDB that is comprehensive while still being fast; you're not the first to reach its limits.
B. On 20 March 2013 13:30, Robin Berjon <[email protected]> wrote: > Hi, > > > On 19/03/2013 20:57 , Pulkit Singhal wrote: >> >> 1) I have a 3rd-party-webhook API calling into my update handler and >> there's nothing I can do to make it pass the document ID in the URL. >> 2) That means the CouchDB server cannot provide the update function with >> the most recent version of that document. >> 3) But the request does provide a payload from which I can pull out the >> document ID ... but by this time I'm inside the update handler function. >> 4) So my question is: If CouchDB did not provide a doc, is there still a >> way for me to: >> a) either, fetch the latest version of the doc myself? >> b) or, override the existing document with another document formed with my >> request payload ... without running into a revision conflict? >> >> I know that I can probably route the request through a proxy that parses >> the payload, sets the document ID onto the request URL and sends it own >> its >> way ... but I'd rather leave that as a last resort. > > > I had a similar problem trying to get a CouchApp to support nice URLs with > nice-looking IDs. Sadly, I couldn't get it to work for my case, but there > may be a solution for you depending on how the third party that's contacting > you is working. *If* it follows redirects, then when you get a request > without an ID you can extract it from the payload and issue a redirect to > the URL with the ID. This doesn't work reliably with browsers (which is why > I couldn't use it) but the odds are it might work for you. > > I had also worked on a patch that made Couch's rewrite system more powerful > in order to handle precisely this case (since right now you simply can't > both have nice URLs and be properly RESTful with Couch), but it wasn't very > popular. If you have the time and energy to address the problems that people > had with it, you can find it at: > > https://github.com/apache/couchdb/pull/38 > > -- > Robin Berjon - http://berjon.com/ - @robinberjon
