use arrow fn to avoid var self = this

master
Tejas Manohar 2015-10-08 23:49:17 -05:00 committed by Jonathan Ong
parent ed19e67055
commit 91ecce1d76
1 changed files with 2 additions and 3 deletions

View File

@ -119,13 +119,12 @@ app.callback = function(){
const fn = this.experimental
? compose_es7(this.middleware)
: co.wrap(compose(this.middleware));
const self = this;
if (!this.listeners('error').length) this.on('error', this.onerror);
return function(req, res){
return (req, res) => {
res.statusCode = 404;
const ctx = self.createContext(req, res);
const ctx = this.createContext(req, res);
onFinished(res, ctx.onerror);
fn.call(ctx).then(function () {
respond.call(ctx);