2015-04-23 10:36:02 +00:00
|
|
|
|
2015-10-11 22:59:51 +00:00
|
|
|
'use strict';
|
|
|
|
|
2015-04-23 10:36:02 +00:00
|
|
|
var http = require('http');
|
|
|
|
var koa = require('../..');
|
|
|
|
var app = koa();
|
|
|
|
|
|
|
|
app.experimental = true;
|
|
|
|
|
|
|
|
// number of middleware
|
|
|
|
|
|
|
|
var n = parseInt(process.env.MW || '1', 10);
|
|
|
|
console.log(' %s async middleware', n);
|
|
|
|
|
|
|
|
while (n--) {
|
|
|
|
app.use(async function (next){
|
|
|
|
await next;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
var body = new Buffer('Hello World');
|
|
|
|
|
|
|
|
app.use(async function (next){
|
|
|
|
await next;
|
|
|
|
this.body = body;
|
|
|
|
});
|
|
|
|
|
|
|
|
app.listen(3333);
|