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

Register middleware based on HTTP method #76

Closed
prashantbaid opened this issue Jul 28, 2016 · 3 comments
Closed

Register middleware based on HTTP method #76

prashantbaid opened this issue Jul 28, 2016 · 3 comments
Labels

Comments

@prashantbaid
Copy link

I know it is possible to register middleware functions based on the route. But how do I register middleware functions based on the same route with different HTTP methods.

For example,
/api GET will have a different set of middleware.
/api POST will have a different set of middleware.

@quarterpi
Copy link

I would also like to know if this is possible... after reading through the meddleware readme on npm it doesn't seem to be supported. What I am looking for is something like this app.post(/\/private\/.*/, myMiddleware);. Any thoughts?

@grawk
Copy link
Member

grawk commented Jan 18, 2017

You can test for the HTTP verb within any middleware and whitelist/blacklist certain verbs that way.

@quarterpi
Copy link

@grawk That is what I ended up doing. Thank you for confirming my hunch.

@grawk grawk added the question label Jan 18, 2017
@grawk grawk closed this as completed Jan 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants