Open tombulled opened 1 year ago
Example of roughly what is desired:
from dataclasses import dataclass from typing import Callable from mediate import middleware CallNext = Callable[[str], None] @dataclass class Dog: name: str def _log_message(self, call_next: CallNext, message: str) -> None: print(f"[INFO] Dog {str(self.name)!r} saying message {message!r}") return call_next(message.upper()) @middleware(_log_message) def say(self, message: str) -> None: print(message) dog = Dog(name="Sam")
>>> dog.say("I like sticks") [INFO] Dog 'Sam' saying message 'I like sticks' I like sticks
Example of roughly what is desired: