diff options
Diffstat (limited to 'share/server/render.js')
-rw-r--r-- | share/server/render.js | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/share/server/render.js b/share/server/render.js index 45782d76..9dcfbcd6 100644 --- a/share/server/render.js +++ b/share/server/render.js @@ -210,10 +210,27 @@ var Render = (function() { return s; }; + function isDocRequestPath(info) { + var path = info.path; + return path.length > 5; + }; + function runShow(fun, ddoc, args) { try { + resetList(); Mime.resetProvides(); - var resp = fun.apply(ddoc, args); + var resp = fun.apply(ddoc, args) || {}; + + // handle list() style API + if (chunks.length && chunks.length > 0) { + resp = maybeWrapResponse(resp); + resp.headers = resp.headers || {}; + for(var header in startResp) { + resp.headers[header] = startResp[header] + } + resp.body = chunks.join("") + (resp.body || ""); + resetList(); + } if (Mime.providesUsed) { resp = Mime.runProvides(args[1]); @@ -227,7 +244,11 @@ var Render = (function() { throw(["error", "render_error", "undefined response from show function"]); } } catch(e) { - renderError(e, fun.toSource()); + if (args[0] === null && isDocRequestPath(args[1])) { + throw(["error", "not_found", "document not found"]); + } else { + renderError(e, fun.toSource()); + } } }; |