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).
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:
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:
And the user calls
route.first()
on the last added element, internally it becomes: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).