rskit_httpclient/lib.rs
1#![warn(missing_docs)]
2
3//! Async HTTP client with redacting auth, resilience, destination hardening, and error handling.
4//!
5//! # Features
6//!
7//! - Async HTTP client built on `reqwest`
8//! - Support for Bearer, Basic, and API key authentication with redacted secret storage
9//! - Configurable timeouts, headers, redirects, and injected resilience policies
10//! - URL building with base URL support and destination validation
11//! - Bounded response-body reads
12//! - JSON request/response serialization
13//! - Integrated error handling with `rskit-errors`
14//!
15//! Authentication secrets are stored in [`rskit_security::SecretString`] inside
16//! [`Auth`], so [`Auth`] and [`HttpClientConfig`] debug output redacts bearer
17//! tokens, basic passwords, and API-key values. Prefer [`HttpClientConfig::with_auth`]
18//! or request auth helpers over raw credential headers.
19//!
20//! # Example
21//!
22//! ```no_run
23//! use rskit_httpclient::{HttpClient, HttpClientConfig, Request};
24//!
25//! #[tokio::main]
26//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
27//! let config = HttpClientConfig::new()
28//! .with_base_url("https://api.example.com")
29//! .with_user_agent("my-app/1.0");
30//!
31//! let client = HttpClient::new(config)?;
32//!
33//! // Simple GET request
34//! let resp = client.get("/users").await?;
35//! let text = resp.text()?;
36//! println!("{}", text);
37//!
38//! // GET request with bearer token
39//! let resp = client.send(
40//! Request::get("/protected")
41//! .bearer_token("secret-token")
42//! ).await?;
43//!
44//! // POST request with JSON
45//! let body = serde_json::json!({"name": "Alice"});
46//! let resp = client.post("/users", &body).await?;
47//!
48//! Ok(())
49//! }
50//! ```
51
52pub mod auth;
53pub mod client;
54pub mod config;
55pub mod destination;
56pub mod request;
57pub mod response;
58
59pub use auth::Auth;
60pub use client::HttpClient;
61pub use config::HttpClientConfig;
62pub use destination::DestinationPolicy;
63pub use request::{Request, RequestBody};
64pub use response::{ErrorResponse, Response};