Hi all,
I am using rewrites in order to expose a nice API but I am hitting a problem
with rewrites. The constraints I have are as follows (my app is not a blog, but
I'll use that for examples as it'll be simpler). First, I would like these
three basic operations to work:
GET /blog/this-is-my-title
PUT /blog/this-is-my-title
DELETE /blog/this-is-my-title
So far so good. But the second constraint is that "this-is-my-title" is not the
ID of the relevant documents, but rather the value of one of their fields. It
is unique within a type, but not unique across all types in the DB (otherwise
I'd just use it as the ID and call it a day). So I generate IDs based on
concatenating the type and that field.
I got this working easily for GET and PUT, using rewrites that point
respectively to a view indexed on the right type plus field, and an update
handler that generates the correct ID on the fly.
For DELETE though, I'm stuck. I've tried a bunch of variations from rewriting
to the document itself to rewriting to an update handler that sets the _deleted
attribute but I can't seem to work my way to a solution.
The problem is that I need a rewrite that invariably accepts parameters that
don't fall at the / boundary. Typically:
{
from: "/blog/*"
, to: "../../blog.*"
, method: "DELETE"
}
And that doesn't work. It just invariably encodes the * or :id, or whatnot.
Have I missed something? I of course could simply expose another ID for DELETE
or ugly IDs everywhere, but that completely defeats the point of having
rewrites in the first place.
Thanks for any suggestions!
--
Robin Berjon - http://berjon.com/ - @robinberjon