I tried CouchDB's rewrite function, see: http://docs.couchdb.org/en/2.0.0/api/ddoc/rewrites.html at "Rewrite section a is stringified function", but it seems it doesn't work. I used the example as a base.
This is mydb _design/router rewrites function:
function (req2) {
var path = req2.path.slice(4);
return {path:"../../../"+path.join("/")};
};
mydb design document:
{
"_id": "_design/router",
"_rev": "1-ff8b2d9e12f41de38495d3460e8c10ad",
"rewrites": "function (req2) {\r\n var path = req2.path.slice(4);\r\n\r\n return {path:\"../../../\"+path.join(\"/\")};\r\n}"
}
this code supposed to pass through all requests made to endpoint mydb/_design/router/_rewrite/*
example:
GET localhost:5984/mydb/_design/router/_rewrite/mydb/_all_docs reroutes to mydb/_all_docs
The GET requests are working fine (as expected)
But the POST, PUT, DELETE requests are hanging (no response!).
example:
POST localhost:5984/mydb/_design/router/_rewrite/mydb
Content-Type:application/json
body:{"foo": "bar"}
No error message returns just hanging.
The above request works fine without rewrite! (POST localhost:5984/mydb inserts a new document {"foo": "bar"})
Is this a bug or am I doing something wrong here? If it is a bug where can I report it?
My specs: Win7 64bit, CouchDB 2.0.0
Thanks!