docs: def apply(self, event, document, *args, **kwargs):
          """
          Applies all middleware functions registered against the given
          event in order to the given document.
          """
          for fn in self._handler_dict.get(event, []):
              fn(document, *args, **kwargs)