Skip to main content

InterceptHandler

Trait InterceptHandler 

Source
pub trait InterceptHandler:
    Send
    + Sync
    + 'static {
    // Provided methods
    fn should_intercept_tls(
        &self,
        _host: &str,
        _process_info: Option<&ProcessInfo>,
    ) -> bool { ... }
    fn on_tls_failure(&self, _host: &str, _error: &str) { ... }
    fn on_request(
        &self,
        _request: &RawRequest,
    ) -> impl Future<Output = HandlerDecision> + Send { ... }
    fn on_websocket_start(
        &self,
        _response: &RawResponse,
    ) -> impl Future<Output = ()> + Send { ... }
    fn on_stream_chunk(
        &self,
        _chunk: &StreamChunk,
    ) -> impl Future<Output = ()> + Send { ... }
    fn on_stream_end(
        &self,
        _connection_id: Uuid,
    ) -> impl Future<Output = ()> + Send { ... }
    fn on_response(
        &self,
        _response: &RawResponse,
    ) -> impl Future<Output = ()> + Send { ... }
    fn on_connection_close(&self, _connection_id: Uuid) { ... }
}
Expand description

Trait for intercepting and inspecting proxy traffic.

Implement this trait to receive callbacks for requests, responses, streaming frames, and connection lifecycle events. All methods have default no-op implementations so you only override what you need.

Provided Methods§

Source

fn should_intercept_tls( &self, _host: &str, _process_info: Option<&ProcessInfo>, ) -> bool

Source

fn on_tls_failure(&self, _host: &str, _error: &str)

Source

fn on_request( &self, _request: &RawRequest, ) -> impl Future<Output = HandlerDecision> + Send

Source

fn on_websocket_start( &self, _response: &RawResponse, ) -> impl Future<Output = ()> + Send

Called when a WebSocket upgrade completes (server sent 101).

The response carries the 101 status and upgrade headers (empty body). Fires after on_request and before the first on_stream_chunk. Ordering is guaranteed by the per-flow dispatch queue.

Source

fn on_stream_chunk( &self, _chunk: &StreamChunk, ) -> impl Future<Output = ()> + Send

Source

fn on_stream_end(&self, _connection_id: Uuid) -> impl Future<Output = ()> + Send

Source

fn on_response( &self, _response: &RawResponse, ) -> impl Future<Output = ()> + Send

Source

fn on_connection_close(&self, _connection_id: Uuid)

Called exactly once when the underlying connection is torn down.

This fires after on_stream_end and is the correct place for connection-scoped cleanup (session unbinding, pending state removal). For HTTP/2 multiplexed connections, on_stream_end fires per-stream while on_connection_close fires once for the connection.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§