Permalink
Browse files

Merge branch 'master' into 1.x

  • Loading branch information...
2 parents 6f5f578 + 89703fd commit 569c5139a691547636b991311c4270c9b4fb88c1 @tj tj committed Nov 12, 2010
Showing with 31 additions and 2 deletions.
  1. +1 −1 lib/express/server.js
  2. +1 −1 support/connect
  3. +29 −0 test/express.test.js
View
@@ -358,7 +358,7 @@ Server.prototype.configure = function(env, fn){
return this;
};
return arguments.callee;
-})('get')('post')('put')('delete');
+})('get')('post')('put')('delete')('all');
// Alias delete as "del"
View
@@ -33,6 +33,23 @@ module.exports = {
server.delete('/something/else', function(req, res){
res.send('Destroyed');
});
+
+ server.all('/staff/:id', function(req, res, next){
+ req.staff = { id: req.params.id };
+ next();
+ });
+
+ server.get('/staff/:id', function(req, res){
+ res.send('GET Staff ' + req.staff.id);
+ });
+
+ server.post('/staff/:id', function(req, res){
+ res.send('POST Staff ' + req.staff.id);
+ });
+
+ server.all('*', function(req, res){
+ res.send('requested ' + req.url);
+ });
assert.response(server,
{ url: '/' },
@@ -49,6 +66,18 @@ module.exports = {
assert.response(server,
{ url: '/something/else', method: 'DELETE' },
{ body: 'Destroyed' });
+
+ assert.response(server,
+ { url: '/staff/12' },
+ { body: 'GET Staff 12' });
+
+ assert.response(server,
+ { url: '/staff/12', method: 'POST' },
+ { body: 'POST Staff 12' });
+
+ assert.response(server,
+ { url: '/foo/bar/baz', method: 'DELETE' },
+ { body: 'requested /foo/bar/baz' });
},
'test constructor middleware': function(assert, beforeExit){

0 comments on commit 569c513

Please sign in to comment.