Skip to main content

ObjectResponseHandler

Type Alias ObjectResponseHandler 

Source
pub type ObjectResponseHandler = Box<dyn Fn(Value) -> Value + Send>;
Expand description

Handler for object (closure) response callbacks.

Receives the matched request as JSON and returns the response JSON object. Unlike breakpoint handlers this is mandatory (no auto-continue) — when a request frame without a breakpoint id arrives, the registered closure produces the response that MockServer returns to the caller.

Only Send is required (not Sync): the handler is stored behind a Mutex and only ever invoked from the single WebSocket-read thread, so access is already serialized. This keeps the public mock_with_callback bound to the minimal Fn(HttpRequest) -> HttpResponse + Send + 'static.

Aliased Type§

pub struct ObjectResponseHandler(/* private fields */);