fix simple example

master
TJ Holowaychuk 2013-08-27 22:42:05 -07:00
parent fae98c10ec
commit 0c19a060c4
1 changed files with 12 additions and 12 deletions

View File

@ -30,30 +30,30 @@ app.use(function(next){
app.use(function(next){
return function *(){
yield next;
if (!this.body) return;
this.set('Content-Length', Buffer.byteLength(this.body));
}
});
// custom 404 handler
app.use(function(next){
return function *(){
yield next;
if (this.body) return;
this.status = 404;
this.body = 'Sorry! No luck';
}
});
// response
app.use(function(next){
return function *(){
yield next;
if ('/' != this.url) return;
this.status = 200;
this.body = 'Hello World';
}
});
// custom 404 handler
app.use(function(next){
return function *(){
yield next;
this.status = 404;
this.body = 'Sorry cannot find that!';
console.log(this);
}
});
app.listen(3000);