Skip to main content

Module interceptor

Module interceptor 

Source
Expand description

Request and response interceptors for the Client.

Interceptors allow modifying outgoing requests and inspecting incoming responses without changing individual call sites.

§Example

use typeway_client::{ClientConfig, RequestInterceptor, ResponseInterceptor};
use std::sync::Arc;

let config = ClientConfig::default()
    .request_interceptor(Arc::new(|req| {
        req.header("X-Custom", "value")
    }))
    .response_interceptor(Arc::new(|resp| {
        println!("Response status: {}", resp.status());
    }));

Type Aliases§

RequestInterceptor
A function that modifies outgoing requests before they are sent.
ResponseInterceptor
A function that inspects responses after they are received.