radiate-framework / framework

A WordPress plugin and theme framework
https://radiate-framework.github.io/
MIT License
4 stars 0 forks source link

Assign middleware/prefixes to individual routes without a group, and on a controller #7

Closed BenRutlandWeb closed 3 years ago

BenRutlandWeb commented 3 years ago

Is your feature request related to a problem? Please describe. Currently it's only possible to assign middleware to a group

Describe the solution you'd like A method to add prefixed/middleware onto a single route without grouping. Also to have on a controller

Describe alternatives you've considered grouping - it's excess code

BenRutlandWeb commented 3 years ago

Adding prefixes to individual routes is already possible in the actual route declaration e.g.

Route::get('[prefix]/blah-blah', BlahController::clas);

There is no need to create a new way of adding prefixes.

Adding middleware to individual routes should be done like laravel, with the middleware method on the route, or in the controller constructor.

The router should be refactored to gather the middleware from the group, route and controller BEFORE running the request through the stack.

Route::get('blah-blah', BlahController::class)->middleware('some-middleware');