From ffcaa04d2c80696234c83eb756fb09bc8d59f65f Mon Sep 17 00:00:00 2001 From: TJ Holowaychuk Date: Wed, 22 Feb 2012 19:59:52 -0800 Subject: [PATCH] renamed `res.respondTo()` to `res.format()` since you are not really responding with it, its basically as switch --- lib/response.js | 6 +++--- test/{res.respondTo.js => res.format.js} | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) rename test/{res.respondTo.js => res.format.js} (97%) diff --git a/lib/response.js b/lib/response.js index 4bd8f89d..49473e4c 100644 --- a/lib/response.js +++ b/lib/response.js @@ -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; }, diff --git a/test/res.respondTo.js b/test/res.format.js similarity index 97% rename from test/res.respondTo.js rename to test/res.format.js index 0710f7de..8a320b8d 100644 --- a/test/res.respondTo.js +++ b/test/res.format.js @@ -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('/')