<commit_before>from abc import ABCMeta, abstractmethod


class AbstractEndpoint(metaclass=ABCMeta):

    path = None     # URL, used for get access to API
    handler = None  # class/function for processing request
    methods = []    # list of supported methods (GET, POST, etc.)
    name = None     # short name for route

    def __init__(self, path, handler, methods, name):
        self.path = path
        self.handler = handler
        if type(methods) is str:
            self.methods.append(methods)
        else:
            self.methods.extend(methods)
        self.name = name

    @abstractmethod
    def match(self, path):
        """Checking path on compatible.

        :param path: URL, which used for get access to API.
        """
        pass


class AbstractRouter(metaclass=ABCMeta):

    @abstractmethod
    def process_request(self, request):
        """Handling received request from user.

        :param request: request from user.
        """
        pass<commit_msg>Added middlewares support<commit_after>from abc import ABCMeta, abstractmethod


class AbstractEndpoint(metaclass=ABCMeta):

    path = None     # URL, used for get access to API
    handler = None  # class/function for processing request
    methods = []    # list of supported methods (GET, POST, etc.)
    name = None     # short name for route

    def __init__(self, path, handler, methods, name):
        self.path = path
        self.handler = handler
        if type(methods) is str:
            self.methods.append(methods)
        else:
            self.methods.extend(methods)
        self.name = name

    @abstractmethod
    def match(self, path):
        """Checking path on compatible.

        :param path: URL, which used for get access to API.
        """
        pass


class AbstractRouter(metaclass=ABCMeta):

    def __init__(self, *args, **kwargs):
        super(AbstractRouter, self).__init__()
        self.middlewares = kwargs.get('middlewares', ())

    @property
    def middlewares(self):
        return self._middlewares

    @middlewares.setter
    def middlewares(self, middlewares):
        self._middlewares = list(middlewares)

    @abstractmethod
    def process_request(self, request):
        """Handling received request from user.

        :param request: request from user.
        """
        pass
{'fraction_non_alphanumeric': 0.0895458440445587, 'fraction_numerical': 0.0, 'mean_word_length': 2.3742774566473988, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3269096', 'n_tokens_mistral': 646, 'n_tokens_neox': 627, 'n_words': 202}