def make_middleware_stack(middleware, base):
        """
        Given a list of in-order middleware callable objects `middleware` and a base function `base`, chains them
        together so each middleware is fed the function below, and returns the top level ready to call.

        :param middleware: The middleware stack
        :type middleware: iterable[callable]
        :param base: The base callable that the lowest-order middleware wraps
        :type base: callable

        :return: The topmost middleware, which calls the next middleware ... which calls the lowest-order middleware,
                 which calls the `base` callable.
        :rtype: callable
        """
        for ware in reversed(middleware):
            base = ware(base)
        return base
Given a list of in-order middleware callable objects `middleware` and a base function `base`, chains them
        together so each middleware is fed the function below, and returns the top level ready to call.

        :param middleware: The middleware stack
        :type middleware: iterable[callable]
        :param base: The base callable that the lowest-order middleware wraps
        :type base: callable

        :return: The topmost middleware, which calls the next middleware ... which calls the lowest-order middleware,
                 which calls the `base` callable.
        :rtype: callable