fix: add named function for request and response handlers (#804)
This commit is contained in:
parent
53ed176c13
commit
2600a20eca
1 changed files with 2 additions and 2 deletions
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue