rust_api_calling 1.0.0

A clean, idiomatic Rust HTTP client library with a single core request function and convenient GET/POST wrappers. Features builder pattern configuration, typed responses via serde generics, automatic session/cookie/XSRF management, and structured logging.
Documentation
use std::collections::HashMap;
use std::time::Duration;

/// Per-request configuration that overrides the client's defaults.
///
/// Use the builder methods to set only what you need — everything
/// defaults to `None` (meaning "use the client's default").
///
/// # Example
/// ```
/// use rust_api_calling::RequestConfig;
/// use std::time::Duration;
///
/// let config = RequestConfig::new()
///     .timeout(Duration::from_secs(10))
///     .bearer_token("my-token-123")
///     .header("X-Custom", "value");
/// ```
#[derive(Debug, Clone, Default)]
pub struct RequestConfig {
    /// Override the default timeout for this specific request.
    pub timeout: Option<Duration>,

    /// Additional headers to include in this request.
    pub headers: HashMap<String, String>,

    /// A bearer token for Authorization header (overrides client default).
    pub bearer_token: Option<String>,
}

impl RequestConfig {
    /// Create a new empty `RequestConfig`.
    pub fn new() -> Self {
        Self::default()
    }

    /// Set a custom timeout for this request.
    pub fn timeout(mut self, duration: Duration) -> Self {
        self.timeout = Some(duration);
        self
    }

    /// Set a bearer token for the Authorization header.
    pub fn bearer_token(mut self, token: impl Into<String>) -> Self {
        self.bearer_token = Some(token.into());
        self
    }

    /// Add a custom header to this request.
    pub fn header(mut self, key: impl Into<String>, value: impl Into<String>) -> Self {
        self.headers.insert(key.into(), value.into());
        self
    }
}