update readme middleware style
This commit is contained in:
parent
2d35cdff50
commit
399e2ad255
1 changed files with 8 additions and 13 deletions
11
Readme.md
11
Readme.md
|
@ -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 *(){
|
|
||||||
yield next;
|
|
||||||
this.body = 'Hello World';
|
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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue