On Mar 10, 2010, at 7:47 PM, Robert Newson wrote:

> All,
> 
> I want to retrieve the JSON document or a specific binary attachment
> of it from the same URL, conditional on the Accept header. That is,
> "/db/doc" is either JSON metadata or a binary stream, depending on
> content-type negotiation. The below rewrite enhancement would achieve
> it, I think, but perhaps there's a cleaner way? Right now, I'm adding
> another Erlang module to achieve this but I would really like to do it
> entirely from a design document.
> 
> I'm thinking of writing a new kind of rewrite handler. I have a case
> where it would be very useful to rewrite a URL based on the contents
> of a request header. That is, the presence of a particular header will
> alter the path, but not otherwise;
> 
> {
>   "_id":"_design/foo",
>  "rewrites": {
>    "bar": {
>      "function":"function(req){ if (req.headers["Accept"] == blah) {
> return req.path + "extra";} return req.path"
> 
> that is, the rewrite handler would get a full request object and
> return the rewritten path, and could use anything from the request to
> do so.
> 

we originally decided against an executable rewrite handler for reasons of 
performance.

is there a way to add to the pattern matching api to achieve this?

Chris

> Thoughts?
> B.

Reply via email to