mirror of
https://github.com/zebrajr/express.git
synced 2026-01-15 12:15:27 +00:00
renamed res.respondTo() to res.format()
since you are not really responding with it, its basically as switch
This commit is contained in:
@@ -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;
|
||||
},
|
||||
|
||||
@@ -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('/')
|
||||
Reference in New Issue
Block a user