Permalink
Browse files

Added app.remove() for app.remove.all()

  • Loading branch information...
1 parent b9596d7 commit b33f38b1098ea13e96966615d0f70369e5ad197a @tj tj committed Apr 26, 2011
Showing with 14 additions and 4 deletions.
  1. +4 −1 lib/http.js
  2. +10 −3 test/router.test.js
View
@@ -58,7 +58,6 @@ app.init = function(middleware){
var self = this;
this.cache = {};
this.match = {};
- this.remove = {};
this.lookup = {};
this.settings = {};
this.redirects = {};
@@ -117,6 +116,10 @@ app.init = function(middleware){
this.on('listening', this.registerErrorHandlers.bind(this));
// route lookup methods
+ this.remove = function(url){
+ return self.remove.all(url);
+ };
+
methods.forEach(function(method){
self.match[method] = function(url){
return self.router.match(url, 'all' == method
View
@@ -191,9 +191,6 @@ module.exports = {
app.get('/user', function(){});
app.get('/user', function(){});
app.put('/user', function(){});
- app.get('/user/:id', function(){});
- app.put('/user/:id', function(){});
- app.del('/user/:id', function(){});
app.get('/user').should.have.length(2);
var removed = app.remove.get('/user');
@@ -203,8 +200,18 @@ module.exports = {
removed.should.have.length(0);
app.get('/user').should.have.length(0);
+ app.get('/user/:id', function(){});
+ app.put('/user/:id', function(){});
+ app.del('/user/:id', function(){});
+
app.remove.all('/user/:id').should.have.length(3);
app.remove.all('/user/:id').should.have.length(0);
+
+ app.get('/user/:id', function(){});
+ app.put('/user/:id', function(){});
+ app.del('/user/:id', function(){});
+
+ app.remove('/user/:id').should.have.length(3);
},
'test app.match': function(){

0 comments on commit b33f38b

Please sign in to comment.