def METHOD_NAME(self):
    # setup middlewares
    logger.debug('setup middlewares')
    self.middleware_classes = (
        self.server.settings.CORE_MIDDLEWARES +
        self.server.settings.MIDDLEWARES
    )
    self.middlewares = []
    for i in self.middleware_classes:
        logger.debug('loading %s', i)
        try:
            if isinstance(i, str):
                middleware_class = self.server.acquire(i)
            else:
                middleware_class = i
        except Exception:
            logger.exception('Exception raised while loading %s', i)
            continue
        try:
            self.middlewares.append(middleware_class())
        except Exception:
            logger.exception('Exception raised while initializing %s', i)
    # discover middleware hooks
    logger.debug('discover middleware hooks')
    self.hooks = {
        hook_name: [] for hook_name, _ in self.HOOKS
    }
    for middleware in self.middlewares:
        logger.debug('discovering %s', middleware)
        for hook_name, hook_is_async in self.HOOKS:
            if not hasattr(middleware, hook_name):
                continue
            hook = getattr(middleware, hook_name)
            if not callable(hook):
                continue
            if not hook_is_async and asyncio.iscoroutinefunction(hook):
                logger.error(
                    '%s.%s is a coroutine function',
                    middleware,
                    hook_name,
                )
            self.hooks[hook_name].append(
                (middleware, hook),
            )
            logger.debug('%s.%s discovered', middleware, hook_name)