Routing Rewrite
See original GitHub issueMasonite 4 will have a new routing engine as well as new routing syntax.
We will have a route syntax like this:
from masonite.routes import Route
Route.get('/url/1', 'Controller@show')
Route.post('/url/2', 'Controller@show')
Route.group(
Route.get('/url/3', 'Controller@show')
Route.post('/url/4', 'Controller@show')
)
The routing engine will be a simple Route class with a few helper methods on it. It will support all features of the current routing engine such as compilers, regex, @ style parameters (/users/@id) groups, deeper module controllers, global controllers, object based controllers, etc.
Currently every route is its own class (Get(), Post(), etc) and we have to loop through all of them to find a match. Now we will have a simple find('/request/path'). This abstracts a lot of the logic out and comes a single point of maintenance. Speed improvements, bug fixes, etc will be done there. This is a much simpler approach. Finding a route now becomes:
request.path #== /dashboard/1
Route.find(request.path) #== finds the route that matches the current path
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (8 by maintainers)

Top Related StackOverflow Question
I guess a helper would be available too, to do it the other way around ? => from name to path, with url parameters if there are any
in tests I often need to get url with params (both URL params such as the user id in previous example and GET parameters) so I end up in Django in doing
and it bothers me to have to write this, so the reverse lookup could be able to handle required url params and additional get params, maybe like:
done in M4