def is_middleware(func) -> bool:
if inspect.isfunction(func):<EOL><INDENT>_check = func<EOL>_name = func.__name__<EOL><DEDENT>else:<EOL><INDENT>_check = func.__call__<EOL>_name = func.__class__.__name__<EOL><DEDENT>if not inspect.iscoroutinefunction(_check):<EOL><INDENT>raise UnknownMiddlewareException("<STR_LIT>".format(_name))<EOL><DEDENT>args = list(inspect.signature(_check).parameters.keys())<EOL>if set(args) - MIDDLEWARE_PARAMETER_BOUNDARY:<EOL><INDENT>raise UnknownMiddlewareException("<STR_LIT>"<EOL>"<STR_LIT>".format(_name))<EOL><DEDENT>return True<EOL>
test whether it is a middleware
:return: Boolean