2013-08-17 07:15:57 +00:00
|
|
|
|
2015-10-11 22:59:51 +00:00
|
|
|
'use strict';
|
|
|
|
|
2015-10-05 18:23:47 +00:00
|
|
|
const http = require('http');
|
|
|
|
const koa = require('..');
|
|
|
|
const app = koa();
|
2013-08-17 07:15:57 +00:00
|
|
|
|
|
|
|
// number of middleware
|
|
|
|
|
2015-10-05 18:23:47 +00:00
|
|
|
const n = parseInt(process.env.MW || '1', 10);
|
2015-10-09 04:01:32 +00:00
|
|
|
console.log(` ${n} middleware`);
|
2013-08-17 07:15:57 +00:00
|
|
|
|
|
|
|
while (n--) {
|
2013-11-08 00:15:47 +00:00
|
|
|
app.use(function *(next){
|
2013-12-25 06:12:48 +00:00
|
|
|
yield *next;
|
2013-08-17 07:15:57 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2015-10-05 18:23:47 +00:00
|
|
|
const body = new Buffer('Hello World');
|
2013-08-17 07:15:57 +00:00
|
|
|
|
2013-11-08 00:15:47 +00:00
|
|
|
app.use(function *(next){
|
2013-12-25 06:12:48 +00:00
|
|
|
yield *next;
|
2013-11-08 00:15:47 +00:00
|
|
|
this.body = body;
|
2013-08-17 07:15:57 +00:00
|
|
|
});
|
|
|
|
|
2013-08-28 23:26:58 +00:00
|
|
|
app.listen(3333);
|