Comparing version 2.3.12 to 2.4.0
2.4.0 / 2011-06-28 | ||
================== | ||
* Added chainable `res.status(code)` | ||
* Added `res.json()`, an explicit version of `res.send(obj)` | ||
* Added simple web-service example | ||
2.3.12 / 2011-06-22 | ||
@@ -3,0 +10,0 @@ ================== |
@@ -31,3 +31,3 @@ | ||
exports.version = '2.3.12'; | ||
exports.version = '2.4.0'; | ||
@@ -34,0 +34,0 @@ /** |
@@ -117,5 +117,42 @@ | ||
this.end('HEAD' == this.req.method ? undefined : body); | ||
return this; | ||
}; | ||
/** | ||
* Send JSON response with `obj`, optional `headers`, and optional `status`. | ||
* | ||
* Examples: | ||
* | ||
* res.json(null); | ||
* res.json({ user: 'tj' }); | ||
* res.json('oh noes!', 500); | ||
* res.json('I dont have that', 404); | ||
* | ||
* @param {Mixed} obj | ||
* @param {Object|Number} headers or status | ||
* @param {Number} status | ||
* @return {ServerResponse} | ||
* @api public | ||
*/ | ||
res.json = function(obj, headers, status){ | ||
this.charset = this.charset || 'utf-8'; | ||
this.header('Content-Type', 'application/json'); | ||
return this.send(JSON.stringify(obj), headers, status); | ||
}; | ||
/** | ||
* Set status `code`. | ||
* | ||
* @param {Number} code | ||
* @return {ServerResponse} | ||
* @api public | ||
*/ | ||
res.status = function(code){ | ||
this.statusCode = code; | ||
return this; | ||
}; | ||
/** | ||
* Transfer the file at the given `path`. Automatically sets | ||
@@ -122,0 +159,0 @@ * the _Content-Type_ response header field. `next()` is called |
{ | ||
"name": "express", | ||
"description": "Sinatra inspired web development framework", | ||
"version": "2.3.12", | ||
"version": "2.4.0", | ||
"author": "TJ Holowaychuk <tj@vision-media.ca>", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
105734
2458