examples/vhost/apps/array.js
2013-12-31 15:43:36 +13:00

21 lines
404 B
JavaScript

// rather than koa apps we can also use array
// bundles of middleware to the same effect.
function *responseTime(next){
var start = new Date;
yield next;
var ms = new Date - start;
this.set('X-Response-Time', ms + 'ms');
}
function *index(next) {
yield next;
if ('/' != this.url) return;
this.body = 'Howzit? From bar middleware bundle';
}
module.exports = [
responseTime,
index
];