Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Router#verbs() #169

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Router#verbs() #169

wants to merge 1 commit into from

Conversation

vanodevium
Copy link

Checklist

  • I have ensured my pull request is not behind the main or master branch of the original repository.
  • I have rebased all commits where necessary so that reviewing this pull request can be done without having to merge it first.
  • I have written a commit message that passes commitlint linting.
  • I have ensured that my code changes pass linting tests.
  • I have ensured that my code changes pass unit tests.
  • I have described my pull request and the reasons for code changes along with context if necessary.

xo linting is broken and I have no idea how to fix it


Route#verbs()

First of all, I created this method just as an idea.

In fact, this method will be useful in cases where the callback is just an anonymous function and you need to assign it to several HTTP methods.

router.verbs(['get', 'post'], '/endpoint', function (ctx) {
	ctx.body = "Ok"
})

I absolutely understand that it could be done this way:

router.get('/endpoint', middleware());
router.post('/endpoint', middleware());

but for dynamic programming this method would be much more useful.

@etroynov
Copy link
Contributor

etroynov commented Sep 9, 2023

I think the case where we have to do the same job using multiple methods is rare.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants