couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aurélien Bénel <>
Subject Sending a redirect from a list
Date Mon, 29 Nov 2010 18:49:19 GMT
Hi there,

I'm trying to send a redirect from a list with the following code:

function (head, req) {
 var row = getRow();
 if (row) {
   var url = "/";   // Will be computed from row
   return {"code": 302, "headers":{ "Location": url}};
 } else {
   return({"code": 404, "body": "Not here"});

I got an error 500 in both case, but the process output seems fine to me: 

1> [debug] [<0.1243.0>] OS Process #Port<0.1834> Output :: ["end",[{"code":302,"headers":{"Location":"/"}}]]
1> [error] [<0.936.0>] Badarg error in HTTP request

1> [debug] [<0.1243.0>] OS Process #Port<0.1834> Output :: ["end",[{"code":404,"body":"Not
1> [error] [<0.1224.0>] Badarg error in HTTP request

I got a look at <>,
however it's not very clear to me if "start" has replaced "return" in 0.10 and was replaced
again by "return" in 0.11... Or maybe it's just a random use...
Anyway, I tried with "start" and I was not luckier. 

Anyone who tried to send a redirect?



View raw message