2015-04-23 10:36:02 +00:00
|
|
|
|
2015-10-11 22:59:51 +00:00
|
|
|
'use strict';
|
|
|
|
|
2015-10-05 18:23:47 +00:00
|
|
|
const http = require('http');
|
2015-10-13 06:19:42 +00:00
|
|
|
const Koa = require('../..');
|
|
|
|
const app = new Koa();
|
2015-04-23 10:36:02 +00:00
|
|
|
|
|
|
|
app.experimental = true;
|
|
|
|
|
|
|
|
// number of middleware
|
|
|
|
|
2015-10-11 23:24:42 +00:00
|
|
|
let n = parseInt(process.env.MW || '1', 10);
|
2015-10-09 04:01:32 +00:00
|
|
|
console.log(` ${n} async middleware`);
|
2015-04-23 10:36:02 +00:00
|
|
|
|
|
|
|
while (n--) {
|
|
|
|
app.use(async function (next){
|
|
|
|
await next;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2015-10-05 18:23:47 +00:00
|
|
|
const body = new Buffer('Hello World');
|
2015-04-23 10:36:02 +00:00
|
|
|
|
|
|
|
app.use(async function (next){
|
|
|
|
await next;
|
|
|
|
this.body = body;
|
|
|
|
});
|
|
|
|
|
|
|
|
app.listen(3333);
|