Skip to content

Conversation

@marcuxyz
Copy link
Owner

@marcuxyz marcuxyz commented Nov 11, 2021

You can use Router.all() to register all routes of CRUD.

Router.all("users")

The previous command produce this:

users.create     POST     /users
users.delete     DELETE   /users/<id>
users.edit       GET      /users/<id>/edit
users.index      GET      /users
users.new        GET      /users/new
users.show       GET      /users/<id>
users.update     PUT      /users/<id>

You can also use only parameter to control routes, e.g:

Router.all("messages", only="index show new create")

The previous command produce this:

messages.create  POST     /messages
messages.index   GET      /messages
messages.new     GET      /messages/new
messages.show    GET      /messages/<id>

The paramenter only accept string or array, so, you can use only=["index", "show", "new", "create"]

close #16

@marcuxyz marcuxyz added the improve New feature or request label Nov 11, 2021
@marcuxyz marcuxyz changed the title create Router.all method create al method to register all routes Nov 11, 2021
- now, you can use Router.all to register all routes of crud
@marcuxyz marcuxyz merged commit ae7a81b into main Nov 11, 2021
@marcuxyz marcuxyz deleted the feat/router-all branch November 11, 2021 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improve New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

create a method to register all routes

2 participants