@classmethod
def constraints(cls):
    """
        Get all constraints enforced by class.
        A constraint is used when the middleware is instantiated with a child
        middleware (``protocol1+protocol2://``). The child middleware must be
        a subclass of each class specified by the constraint.

        :returns: list of constraints
        :rtype: list
        """
    bases = cls.mro()
    result = []
    for base in reversed(bases):
        if hasattr(base, '__constraints__'):
            for constraint in base.__constraints__:
                if constraint not in result:
                    result.append(constraint)
    return result
