Skip to main content

Module middleware

Module middleware 

Source
Expand description

Lightweight middleware/interceptor chain for the HTTP client.

Provides a ClientMiddleware trait that lets callers observe and instrument each request/response round-trip without the complex type-erasure required by a full tower::Service composition.

§Example

use oxihttp_client::{Client, middleware::{ClientMiddleware, LoggingMiddleware}};

let client = Client::builder()
    .with_middleware(LoggingMiddleware::new("my-client"))
    .build()
    .expect("client build");

Structs§

LoggingMiddleware
Logging middleware: emits one line to stderr before each request and one line after each response.
RequestContext
Request context passed to ClientMiddleware::before_request.
ResponseContext
Response context passed to ClientMiddleware::after_response.
TimingMiddleware
Timing middleware: invokes a user-supplied callback with the elapsed duration after each successful response.

Traits§

ClientMiddleware
A request/response interceptor that can observe (but not modify) each HTTP round-trip.