4 ms·
They allow you to match the URL in a series of steps. Where each step can be static (ie "/foo") or dynamic (ie /images/). You can then easily add features to t
by jeremiep 10y ago
They allow you to match the URL in a series of steps. Where each step can be static (ie "/foo") or dynamic (ie /images/).
You can then easily add features to this structure, like route middlewares at every level in the tree; just apply them while doing the routing.
This also allows you to match route variants easily, ie "foo" and "foo/" are the same, so are "/" and "/index.html". In the same way you can extract query parameters for middleware/handler use.
- mstade 10y agoAlso, tries means it's trivial to do detect routing ambiguities, so your routing table doesn't necessarily have to be built up front, or in any particular order. This is particularly powerful when you're developing an application with a team distributed both over space and time.