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

method_decorator unused? #15

Closed
joshuar500 opened this issue May 20, 2019 · 2 comments
Closed

method_decorator unused? #15

joshuar500 opened this issue May 20, 2019 · 2 comments

Comments

@joshuar500
Copy link

first, just wanna say thank you for making this project.

i noticed that method_decorator is assigned [jwt_required] but it isn't used? not sure if i'm reading it correctly, but maybe it belongs above the put and delete requests as @method_decorator by default? or is it up to the user to decide...

@karec
Copy link
Owner

karec commented May 21, 2019

Hi @joshuar500

method_decorator comes from flask-restFul itself (https://flask-restful.readthedocs.io/en/0.3.5/extending.html#resource-method-decorators), it's used to apply decorators to all methods of the resource.

A good thing to know is that if you want to apply this decorator only to some methods (for example like you said on put and delete requests only), you can use a mapping like this:

method_decorators = {
    "put": [jwt_required],
    "delete": [jwt_required]
}

You can see how this property is used in flask-restFul's source code here: https://github.com/flask-restful/flask-restful/blob/master/flask_restful/__init__.py#L572

Hope this has answered your question !

@joshuar500
Copy link
Author

Awesome! Thank you very much!

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

No branches or pull requests

2 participants