fix: add named function for request and response handlers (#804)

This commit is contained in:
fengmk2 2016-08-31 10:24:28 +08:00 committed by GitHub
parent 53ed176c13
commit 2600a20eca

View file

@ -129,11 +129,11 @@ app.callback = function(){
if (!this.listeners('error').length) this.on('error', this.onerror); if (!this.listeners('error').length) this.on('error', this.onerror);
return function(req, res){ return function handleRequest(req, res){
res.statusCode = 404; res.statusCode = 404;
var ctx = self.createContext(req, res); var ctx = self.createContext(req, res);
onFinished(res, ctx.onerror); onFinished(res, ctx.onerror);
fn.call(ctx).then(function () { fn.call(ctx).then(function handleResponse() {
respond.call(ctx); respond.call(ctx);
}).catch(ctx.onerror); }).catch(ctx.onerror);
} }