This repository was archived by the owner on Mar 6, 2025. It is now read-only.

Description
Hi is there a way to define a decorator with paramaters like the CORS one.
Many thanks for help and thoughts, not sure if i am just not understanding the syntax to use or its not possible,
I have two use cases.
- On exception be able to define a friendly message per handler for error responses
@on_exception
def handle_errors(exception,friendlyMesssage="Something went wrong"):
print(exception)
return {'statusCode': 500, 'body':friendlyMesssage}
@handle_errors(friendlyMesssage="Failed to get something")
def getSomething(event, context):
#do something
- On before - i am writing a middleware to implenent RBAC (role based access control) and want o provide the list of permissions required to call the function
@before
def rbac(event, context,permissions=[]):
print(f'required permissions {" ".join(str(x) for x in permissions)}')
# actually do the validation
@rbac(permissions=["get:dogs","put:badgers"])
def getSomething(event, context):
#do something