def is_middleware(target):
    """Mostly for internal use, this function returns True if *target* is
    a valid face middleware.

    Middlewares can be functions wrapped with the
    :func:`face_middleware` decorator, or instances of a user-created
    type, as long as it's a callable following face's signature
    convention and has the ``is_face_middleware`` attribute set to
    True.
    """
    if callable(target) and getattr(target, 'is_face_middleware', None):
        return True
    return False
