Closed Cinamonas closed 8 years ago
Thanks for this.
I'm reluctant to change this however for various reasons. First up is backwards compatibility - I don't want to break it for existing users. Secondly, the order depends on your transpiler; the spec hasn't completely congealed on this, and for example, babel recently changed the order it does it in.
Lastly, although this is totally up to interpretation, it's not necessarily backwards if you think about it as successively wrapping the handler in function calls, kind of like get('/', a(b(c(fn))))
. In this case it would execute inside out.
Given the following code:
Middlewares will be executed in such order: c → b → a. Which is not what you'd expect.
As a quick workaround, I changed the order in which I attach middlewares, but I guess it's something that could be addressed at library level.