Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

append / prepend for middleware #326

tj opened this Issue Jul 21, 2011 · 2 comments


None yet
2 participants

tj commented Jul 21, 2011

i personally love the look of use() and it's unified between stylus, cluster, connect, etc. I'm not sure I',m ready to ditch it yet but we do need some way to prepend and inject middleaware after a stack is constructed. unfortunately since they are only named via function name, and many in third-party middleware are not named, the following might not yet be possible:


the one thing we could probably add is prepend / append, which helps for some cases, but I'm not sure it helps enough to remove use()

This issue is 2 years old. Was there any move in this direction? I would also like this feature. One solution would be to have a layer on top of connect that builds the middleware chain while requiring for each middleware to be labeled. Any chance this would get merged if I implement it? Otherwise I will work on a third party library.

layer.use(connect.bodyParser, 'bodyParser');
layer.use(connect.cookies, 'cookies');

/* .... */
layer.use(function (req, res, cb) { /* .... */}, 'custom-middleware').before('bodyParser')

Since this is 2 years old, I've created a new issue (#810).

@tj tj closed this Jul 6, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment