I have created a class based AWS lambda function in python called requestHandler.py as below
from action_dispatcher import ActionDispatcher
class RequestHandler(ActionDispatcher):
@staticmethod
def createTemplate(event, context):
return "Hello world"
My action_dispatcher.py is as shown below.
import json
class ActionDispatcher(object):
def __call__(self, event, context, *args, **kwargs):
action = event.get('action')
handler = getattr(self, action, None)
if handler is None:
return json.loads({'status': 'error', 'code': 404, 'message':"Action {0} not found.".format(action) })
return handler(request, *args, **kwargs)
With this above setup and lambda handler as requestHandler.RequestHandler, i get error "RequestHandler() takes no arguments" in this case i create action as createTemplate. so i want to call this method from RequestHandler.