4 ms·
You are 100% correct, I forgot about that extra group (that doesn't need to be there). That being said, most frameworks don't have multiple matching routes, an
by andrewvc 12y ago
You are 100% correct, I forgot about that extra group (that doesn't need to be there).
That being said, most frameworks don't have multiple matching routes, and I can't imagine that many people miss them. I've never used a framework that supported that, and I can't say I've ever felt I've missed out. Middleware is the right approach to that problem generally.
- thedufer 12y agoThe point is to be able to have middleware that only runs on certain urls. For example, you might have middleware that only runs on a particular version of your API (`regexp: ^/1\/.*/`). I've used it fairly extensively. The point being, now you're describing a completely different, less powerful framework. Which, yes, of course it's faster. You'll notice that's what Netflix ended up doing - they moved to `restify` from `express`. You might as well just only allow routes to be strings and then you have the constant-time map implementation that the article describes as the expected implementation.