koa-lite/benchmarks/middleware.js

27 lines
384 B
JavaScript
Raw Normal View History

2013-08-17 07:15:57 +00:00
'use strict';
2013-08-17 07:15:57 +00:00
var http = require('http');
var koa = require('..');
var app = koa();
// number of middleware
var n = parseInt(process.env.MW || '1', 10);
console.log(' %s middleware', n);
while (n--) {
app.use(function *(next){
2013-12-25 06:12:48 +00:00
yield *next;
2013-08-17 07:15:57 +00:00
});
}
var body = new Buffer('Hello World');
app.use(function *(next){
2013-12-25 06:12:48 +00:00
yield *next;
this.body = body;
2013-08-17 07:15:57 +00:00
});
2013-08-28 23:26:58 +00:00
app.listen(3333);