Browse files

createServer() should accept middleware.

  • Loading branch information...
1 parent 2be1587 commit 4ca1292687f801d06c0578ba5cdcc605ebbde6c5 @stephank committed Mar 28, 2012
Showing with 16 additions and 1 deletion.
  1. +4 −1 lib/connect.js
  2. +12 −0 test/mounting.js
View
5 lib/connect.js
@@ -61,7 +61,10 @@ function createServer() {
utils.merge(app, proto);
utils.merge(app, EventEmitter.prototype);
app.route = '/';
- app.stack = [].slice.apply(arguments);
+ app.stack = [];
+ [].forEach.call(arguments, function(fn) {
+ app.use(fn);
+ });
return app;
};
View
12 test/mounting.js
@@ -2,6 +2,18 @@
var connect = require('../')
, http = require('http');
+describe('createServer()', function(){
+ it('should accept middleware', function(done){
+ var app = connect(function(req, res, next) {
+ res.end('blog');
+ });
+
+ app.request()
+ .get('/')
+ .expect('blog', done);
+ });
+});
+
describe('app.use()', function(){
var app;

0 comments on commit 4ca1292

Please sign in to comment.