renamed res.respondTo() to res.format()

since you are not really responding with it,
its basically as switch
This commit is contained in:
TJ Holowaychuk
2012-02-22 19:59:52 -08:00
parent a47660ba67
commit ffcaa04d2c
2 changed files with 5 additions and 5 deletions

View File

@@ -300,7 +300,7 @@ res.type = function(type){
*
* Examples:
*
* res.respondTo({
* res.format({
* 'text/plain': function(){
* res.type('text').send('hey');
* },
@@ -319,7 +319,7 @@ res.type = function(type){
* @api public
*/
res.respondTo = function(obj){
res.format = function(obj){
var keys = Object.keys(obj)
, req = this.req
, next = req.next
@@ -541,7 +541,7 @@ res.redirect = function(url){
}
// Support text/{plain,html} by default
this.respondTo({
this.format({
'text/plain': function(){
body = statusCodes[status] + '. Redirecting to ' + url;
},

View File

@@ -7,7 +7,7 @@ var express = require('../')
var app = express();
app.use(function(req, res, next){
res.respondTo({
res.format({
'text/plain': function(){
res.send('hey');
},
@@ -30,7 +30,7 @@ app.use(function(err, req, res, next){
})
describe('req', function(){
describe('.respondTo(obj)', function(){
describe('.format(obj)', function(){
it('should utilize qvalues in negotiation', function(done){
request(app)
.get('/')