You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by "Benjamin Young (JIRA)" <ji...@apache.org> on 2014/02/28 16:30:20 UTC

[jira] [Created] (COUCHDB-2181) Show function with provides() fails to handle `json` key

Benjamin Young created COUCHDB-2181:
---------------------------------------

             Summary: Show function with provides() fails to handle `json` key
                 Key: COUCHDB-2181
                 URL: https://issues.apache.org/jira/browse/COUCHDB-2181
             Project: CouchDB
          Issue Type: Bug
      Security Level: public (Regular issues)
          Components: JavaScript View Server
            Reporter: Benjamin Young


The documentation for [Show functions|http://docs.couchdb.org/en/latest/couchapp/ddocs.html#show-functions] has the following code:
{code:javascript}
function(doc, req){
  provides('json', function(){
    return {'json': doc}
  });
}
{code}

However, using that returns an empty body—though it does properly set Content-Type, etc.

The cause is that the ‘json’ key is not checked/processed by the Mime and/or Render code, but should be if the response type is JSON (at least).

Short term fix: update the docs to use the {{\{body: JSON.stringify(doc)\}}} return value instead.

Long(er) term / more-correct fix: fix the Mime/Render code to address…and then put the docs back the way they are currently (if we did the short term fix).



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)