[Feature Request] - Resource and Any route
Closed this issue · 0 comments
javad-zobeidi commented
Is your feature request related to a problem? Please describe.
The current Router class lacks built-in support for defining routes that can handle any HTTP method any
and for creating standard RESTful resource
routes resource
This makes it cumbersome to manage routes efficiently, requiring repetitive code and manual setup for each HTTP method and resource route.
Describe the solution you'd like
I would like the Router class to include the following methods:
Router.any
: A method to define routes that respond to any HTTP method, allowing for flexible and DRY (Don't Repeat Yourself) route definitions.Router.resource
: A method to create standard RESTful resource routes (index
,create
,store
,show
,edit
,update
,destroy
) with built-in support for parameter validation.
Describe alternatives you've considered
Manually Defining Routes: Manually defining each route for resource controllers and any method handlers, which leads to repetitive code and a higher risk of errors.
Additional context
// Example of using any method to handle any HTTP method
Router.any('req/any', (Request request) {
return Response.json(request.all());
});
// Example of defining resource routes with validation
Router.resource('posts', PostController())
.prefix('admin')
.middleware([AuthMiddleware()]);