def registerHandlers()

in core/actionProxy/owplatform/knative.py [0:0]


    def registerHandlers(self, initCodeImp, runCodeImp):

        self.initCode = initCodeImp
        self.runCode = runCodeImp

        httpMethods = os.getenv('__OW_HTTP_METHODS', DEFAULT_METHOD)
        # try to turn the environment variable into a list if it is in the right format
        if isinstance(httpMethods, str) and httpMethods[0] == '[' and httpMethods[-1] == ']':
            httpMethods = httpMethods[1:-1].split(',')
        # otherwise just default if it is not a list
        elif not isinstance(httpMethods, list):
            httpMethods = DEFAULT_METHOD

        httpMethods = {m.upper() for m in httpMethods}

        # use some fancy set operations to make sure all the methods are valid
        # and remove any that aren't
        invalidMethods = httpMethods.difference(set(VALID_METHODS))
        validMethods = list(httpMethods.intersection(set(VALID_METHODS)))
        if len(invalidMethods) > 0:
            for invalidMethod in invalidMethods:
                print("Environment variable '__OW_HTTP_METHODS' has an unrecognised value (" + invalidMethod + ").",
                      file=sys.stderr)

        self.proxy.add_url_rule('/', 'run', self.run, methods=validMethods)