On Mon, Jan 25, 2010 at 6:06 AM, Chris Anderson <jch...@apache.org> wrote: > On Sun, Jan 24, 2010 at 11:00 AM, Benoit Chesneau <bchesn...@gmail.com> wrote: >> Hi, >> >> Folloging suggestion of @jchris I revisited my rewrite handler. This >> time instead of using a javascript function to handle rewriting it >> uses pattern matching in Erlang to do it. The rewriting root is the >> the design doc : >> >> /yourdb/_design/ddocname/_rewrite/.... >> >> ddocname should contain a "rewrites" member which a list of rewriting >> rules. If not it will return a 404. >> >> ex : >> >> { >> .... >> "rewrite": [ >> { >> "from": "", >> "to": "index.html", >> "method": "GET", >> "query": {} >> } >> ] >> } >> >> Urls are relatives to the db if they start by / or to the current path. >> >> Rewriting can use variables. Variables in path are prefixed by ":". >> For example the following rule: >> >> { "from": "show/:id", "to": "_show/mydoc/:id" } >> >> will rewrite >> "/mydb/_design/test/_rewrite/show/someid" to >> "/mydb/_design/test/_rewrite/_show/someid". >> > > do you mean? > > "/mydb/_design/test/_show/someid"
yes sorry. > >> or { "from": "view/:type", "to": "_list/types/by_types", query: { >> "key": "type" } >> will rewrite : >> >> "/mydb/_design/test/_rewrite/view/sometype" to >> "/mydb/_design/test/_rewrite/_list/types/by_types?key=sometype". >> > > do you mean? > > "/mydb/_design/test/_list/types/by_types?key=sometype" and yes. Lack of sleep I guess