update readme middleware style

This commit is contained in:
TJ Holowaychuk 2013-11-07 16:31:16 -08:00
parent 2d35cdff50
commit 399e2ad255

View file

@ -42,22 +42,17 @@ var app = koa();
// logger // logger
app.use(function(next){ app.use(function *(next){
return function *(){ var start = new Date;
var start = new Date; yield next;
yield next; var ms = new Date - start;
var ms = new Date - start; console.log('%s %s - %s', this.method, this.url, ms);
console.log('%s %s - %s', this.method, this.url, ms);
}
}); });
// response // response
app.use(function(next){ app.use(function *(){
return function *(){ this.body = 'Hello World';
yield next;
this.body = 'Hello World';
}
}); });
app.listen(3000); app.listen(3000);
@ -110,8 +105,8 @@ $ make test
## Authors ## Authors
- [TJ Holowaychuk](https://github.com/visionmedia) - [TJ Holowaychuk](https://github.com/visionmedia)
- [Julian Gruber](https://github.com/juliangruber)
- [Jonathan Ong](https://github.com/jonathanong) - [Jonathan Ong](https://github.com/jonathanong)
- [Julian Gruber](https://github.com/juliangruber)
# License # License