Skip to main content

Module hooks

Module hooks 

Source
Expand description

Lifecycle hooks for requests and responses.

Buffered responses use Hooks::on_response / Hooks::on_success. Streaming responses (RequestBuilder::send_stream) use Hooks::on_response_stream / Hooks::on_success_stream with status and headers only (no body).

Hooks::on_request and Hooks::on_response / Hooks::on_response_stream return Result. To abort the client pipeline intentionally, return Err(Error::hook("reason")). Hooks::on_success, Hooks::on_success_stream, Hooks::on_error, and Hooks::on_retry cannot return errors.

Structs§

ErrorContext
Context when an error occurs.
Hooks
Lifecycle hooks for the HTTP client.
RequestContext
Context for an outgoing request.
ResponseContext
Context after a buffered response is received.
StreamingResponseContext
Context after a streaming response is received (headers only; body not consumed).
StreamingResponseMeta
Metadata returned from streaming response hooks.
StreamingSuccessContext
Context after a successful streaming response (2xx, metadata only).
SuccessContext
Context after a successful HTTP response (2xx).