examples/vhost/apps/array.js
2016-10-20 13:12:07 +08:00

21 lines
409 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
];