expose the Application::handleRequest method
This commit is contained in:
parent
2f8df368ff
commit
a558d306ba
1 changed files with 9 additions and 5 deletions
|
@ -130,13 +130,17 @@ 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 handleRequest(req, res){
|
return function handleRequest(req, res){
|
||||||
res.statusCode = 404;
|
|
||||||
var ctx = self.createContext(req, res);
|
var ctx = self.createContext(req, res);
|
||||||
onFinished(res, ctx.onerror);
|
app.handleRequest(ctx, fn);
|
||||||
fn.call(ctx).then(function handleResponse() {
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
app.handleRequest = function(ctx, fnMiddleware){
|
||||||
|
ctx.res.statusCode = 404;
|
||||||
|
onFinished(ctx.res, ctx.onerror);
|
||||||
|
fnMiddleware.call(ctx).then(function handleResponse() {
|
||||||
respond.call(ctx);
|
respond.call(ctx);
|
||||||
}).catch(ctx.onerror);
|
}).catch(ctx.onerror);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue