aiohttp_utils/routing.py
def add_resource_object(self, path: str, resource, methods: tuple=tuple(), names: Mapping=None):
        """Add routes by an resource instance's methods.

        :param path: route path. Should be started with slash (``'/'``).
        :param resource: A "resource" instance. May be an instance of a plain object.
        :param methods: Methods (strings) to register.
        :param names: Dictionary of ``name`` overrides.
        """
        names = names or {}
        if methods:
            method_names = methods
        else:
            method_names = self.HTTP_METHOD_NAMES
        for method_name in method_names:
            handler = getattr(resource, method_name, None)
            if handler:
                name = names.get(method_name, self.get_default_handler_name(resource, method_name))
                self.add_route(method_name.upper(), path, handler, name=name)
def add_resource_object(self, path: str, resource, methods: tuple=tuple(), names: Mapping=None):
        """Add routes by an resource instance's methods.

        :param path: route path. Should be started with slash (``'/'``).
        :param resource: A "resource" instance. May be an instance of a plain object.
        :param methods: Methods (strings) to register.
        :param names: Dictionary of ``name`` overrides.
        """
        names = names or {}
        if methods:
            method_names = methods
        else:
            method_names = self.HTTP_METHOD_NAMES
        for method_name in method_names:
            handler = getattr(resource, method_name, None)
            if handler:
                name = names.get(method_name, self.get_default_handler_name(resource, method_name))
                self.add_route(method_name.upper(), path, handler, name=name)
Add routes by an resource instance's methods.

        :param path: route path. Should be started with slash (``'/'``).
        :param resource: A "resource" instance. May be an instance of a plain object.
        :param methods: Methods (strings) to register.
        :param names: Dictionary of ``name`` overrides.