remove errors, hello world, and stream examples
This commit is contained in:
parent
017bfef8ba
commit
08797ccb0b
3 changed files with 0 additions and 59 deletions
|
@ -1,37 +0,0 @@
|
|||
|
||||
var koa = require('..');
|
||||
var app = koa();
|
||||
|
||||
// look ma, error propagation!
|
||||
|
||||
app.use(function *(next){
|
||||
try {
|
||||
yield next;
|
||||
} catch (err) {
|
||||
// some errors will have .status
|
||||
// however this is not a guarantee
|
||||
this.status = err.status || 500;
|
||||
this.type = 'html';
|
||||
this.body = '<p>Something <em>exploded</em>, please contact Maru.</p>';
|
||||
|
||||
// since we handled this manually we'll
|
||||
// want to delegate to the regular app
|
||||
// level error handling as well so that
|
||||
// centralized still functions correctly.
|
||||
this.app.emit('error', err, this);
|
||||
}
|
||||
});
|
||||
|
||||
// response
|
||||
|
||||
app.use(function *(){
|
||||
throw new Error('boom boom');
|
||||
});
|
||||
|
||||
// error handler
|
||||
|
||||
app.on('error', function(err){
|
||||
console.log('sent error %s to the cloud', err.message);
|
||||
});
|
||||
|
||||
app.listen(3000);
|
|
@ -1,9 +0,0 @@
|
|||
|
||||
var koa = require('..');
|
||||
var app = koa();
|
||||
|
||||
app.use(function *(){
|
||||
this.body = 'Hello World';
|
||||
});
|
||||
|
||||
app.listen(3000);
|
|
@ -1,13 +0,0 @@
|
|||
|
||||
var koa = require('..');
|
||||
var fs = require('fs');
|
||||
var app = koa();
|
||||
|
||||
// try GET /streams.js
|
||||
|
||||
app.use(function *(){
|
||||
var path = __dirname + this.path;
|
||||
this.body = fs.createReadStream(path);
|
||||
});
|
||||
|
||||
app.listen(3000);
|
Loading…
Reference in a new issue