Consider: resolve next with ctx
omsmith opened this issue · comments
As is, a middleware which acts on the return path will consistently redefine the handler for the call to next
:
module.exports = (ctx, next) => {
// down
return next().then(() => {
// up
});
};
By resolving next
with ctx
, the handler could be hoisted:
const myMiddlewareUp = (ctx) => {
// up
};
module.exports = (ctx, next) => {
// down
return next().then(myMiddlewareUp);
};
Err, fat fingered - will get it edited
I suppose you could easily do next().then(() => up(ctx))
. This cold must be getting to me.