use arrow fn to avoid var self = this

This commit is contained in:
Tejas Manohar 2015-10-08 23:49:17 -05:00 committed by Jonathan Ong
parent ed19e67055
commit 91ecce1d76

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);