vert-x3 / issues

Apache License 2.0
36 stars 7 forks source link

Revisit router internals to avoid misconfigurations (e.g.: shaded routes) #592

Closed pmlopes closed 2 years ago

pmlopes commented 2 years ago

Vert.x router is a simple sequence of routes that get evaluated in order.

This simplicity works, yet it requires users to be aware of shading of routes, for example:

/foo/*
/foo/:id

Given the request: /foo/bar

Both routes are valid, but should we consider bar as :id or *?

The behavior is undefined and currently it's solved by the order the route has been added.

This would be fine, except, we also allow re-ordering of routes in real time, so for example:

/foo/*
/*

And the user calls route.first() on the last added element, internally it becomes:

/*
/foo/*

And the 1st entry will shade all other routes. Unless this route handler calls ctx.next() no further routes will be reached.

The goal is to define a set of rules on automatically sorting the routes and issue illegal state exceptions when these cases are generated (so users don't end up with a non working router).