Skip to content

Commit

Permalink
Fix view_func wrapper with multiple decorators
Browse files Browse the repository at this point in the history
  • Loading branch information
NadavTasher committed Feb 7, 2024
1 parent 411b44b commit c58c3e1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions image/src/backend/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class Router(Flask):

def add_url_rule(self, rule, endpoint=None, view_func=None, provide_automatic_options=None, **options):
def add_url_rule(self, rule, endpoint=None, view_func=None, **options):
# Fetch all of the required types
required_types = {
# Create a key: value without prefix
Expand All @@ -37,7 +37,7 @@ def add_url_rule(self, rule, endpoint=None, view_func=None, provide_automatic_op
}

# Create wrapper function
def view_func_wrapper(**flask_kwargs):
def wrapper(**flask_kwargs):
try:
# Update the kwargs with JSON parameters
if request.is_json:
Expand Down Expand Up @@ -96,8 +96,11 @@ def view_func_wrapper(**flask_kwargs):
# Return the error response
return response, 500

# Create the endpoint name
endpoint = endpoint or rule + repr(options.get("methods", []))

# Add the url rule using the parent
return super(Router, self).add_url_rule(rule, endpoint or view_func.__name__ + "_" + repr(options.get("methods")), view_func_wrapper if view_func else view_func, provide_automatic_options, **options)
return super(Router, self).add_url_rule(rule, endpoint, wrapper if view_func else view_func, **options)


# Initialize the application
Expand Down

0 comments on commit c58c3e1

Please sign in to comment.