Closed lukeed closed 6 years ago
I think your current work around is cool.. Probably using the current workaround will be okay so far it doesn't affect the speed of polka.
I'm strongly in favor of per route middleware. I just faced a case when I need to use different body-parser
options for each route. I had to workaround it like shown in the example in docs (pathname.startsWith
etc). but that's really not a pretty solution in my opinion.
@plakak I hear ya. Still deciding. Please remember that you can can attach a global middleware that specifies which parser to use based on Content-Type
. This is how that body-parser
package works in the first place~!
Currently, Polka only allows 1 handler per route pattern. Express, on the other hand, allows you to assign as many as you want, constructing per-route middleware groups.
This is still a maybe as it would require changes to
Trouter
. Speed is still the #1 priority, and you can already achieve similar behavior by manually calling middleware from within the single handler.Current "workaround"