<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def register(self, endpoint, scheme=None, handler=None, **kwargs):
 """Register a handler with this TChannel. This may be used as a decorator: .. code-block:: python app = TChannel(name='bar') @app.register("hello", "json") def hello_handler(request, response):
 params = yield request.get_body() Or as a function: .. code-block:: python # Here we have a Thrift handler for `Foo::hello` app.register(Foo, "hello", hello_thrift_handler) :param endpoint: Name of the endpoint being registered. This should be a reference to the Thrift-generated module if this is a Thrift endpoint. It may also be ``TChannel.FALLBACK`` if it's intended to be a catch-all endpoint. :param scheme: Name of the scheme under which the endpoint is being registered. One of "raw", "json", and "thrift". Defaults to "raw", except if "endpoint" was a module, in which case this defaults to "thrift". :param handler: If specified, this is the handler function. If ignored, this function returns a decorator that can be used to register the handler function. :returns: If ``handler`` was specified, this returns ``handler``. Otherwise, it returns a decorator that can be applied to a function to register it as the handler. """

        assert endpoint is not None, "endpoint is required"

        if endpoint is TChannel.FALLBACK:
            decorator = partial(self._handler.register, TChannel.FALLBACK)
            if handler is not None:
                return decorator(handler)
            else:
                return decorator

        if not scheme:
            # scheme defaults to raw, unless the endpoint is a service module.
            if inspect.ismodule(endpoint):
                scheme = "thrift"
            else:
                scheme = "raw"
        scheme = scheme.lower()
        if scheme == 'thrift':
            decorator = partial(self._register_thrift, endpoint, **kwargs)
        else:
            decorator = partial(
                self._register_simple, endpoint, scheme, **kwargs
            )

        if handler is not None:
            return decorator(handler)
        else:
            return decorator