Interceptor
interface:
message_type
: Type of the message (e.g., “text”, “binary”, “close”, “ping”, “pong”) - Requireddata
: The actual message content (bytes or str) - Requiredclose_code
: Close code for close messages (optional)close_reason
: Human-readable close reason (optional)is_final
: Whether this is the final frame in a fragmented message (optional)target
: WebSocket URL (ws:// or wss://) - Required (inherited from Outbound)message_type
: Type of the message to send (e.g., “text”, “binary”, “close”, “ping”, “pong”) - Requireddata
: The message content to send (bytes or str) - Requiredheaders
: HTTP headers for WebSocket handshake (optional)subprotocols
: List of WebSocket subprotocols (optional)close_code
: Close code for close messages (optional)close_reason
: Human-readable close reason (optional).copy()
when modifying inbound/outbound data to avoid side effectsawait next_interceptor(data)
unless you want to short-circuitmessage_type
, target
, or data content to handle different scenariosnext_interceptor()
to stop the chainnext_interceptor()
for pre-processing, after for post-processing