[breaking change] don't bind onerror to context (#800)
This commit is contained in:
parent
614b4e1ad7
commit
4338cb6c14
2 changed files with 4 additions and 4 deletions
|
@ -131,8 +131,9 @@ module.exports = class Application extends Emitter {
|
||||||
return (req, res) => {
|
return (req, res) => {
|
||||||
res.statusCode = 404;
|
res.statusCode = 404;
|
||||||
const ctx = this.createContext(req, res);
|
const ctx = this.createContext(req, res);
|
||||||
onFinished(res, ctx.onerror);
|
const onerror = err => ctx.onerror(err);
|
||||||
fn(ctx).then(() => respond(ctx)).catch(ctx.onerror);
|
onFinished(res, onerror);
|
||||||
|
fn(ctx).then(() => respond(ctx)).catch(onerror);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +153,6 @@ module.exports = class Application extends Emitter {
|
||||||
request.ctx = response.ctx = context;
|
request.ctx = response.ctx = context;
|
||||||
request.response = response;
|
request.response = response;
|
||||||
response.request = request;
|
response.request = request;
|
||||||
context.onerror = context.onerror.bind(context);
|
|
||||||
context.originalUrl = request.originalUrl = req.url;
|
context.originalUrl = request.originalUrl = req.url;
|
||||||
context.cookies = new Cookies(req, res, {
|
context.cookies = new Cookies(req, res, {
|
||||||
keys: this.keys,
|
keys: this.keys,
|
||||||
|
|
|
@ -164,7 +164,7 @@ module.exports = {
|
||||||
// stream
|
// stream
|
||||||
if ('function' == typeof val.pipe) {
|
if ('function' == typeof val.pipe) {
|
||||||
onFinish(this.res, destroy.bind(null, val));
|
onFinish(this.res, destroy.bind(null, val));
|
||||||
ensureErrorHandler(val, this.ctx.onerror);
|
ensureErrorHandler(val, err => this.ctx.onerror(err));
|
||||||
|
|
||||||
// overwriting
|
// overwriting
|
||||||
if (null != original && original != val) this.remove('Content-Length');
|
if (null != original && original != val) this.remove('Content-Length');
|
||||||
|
|
Loading…
Reference in a new issue