Skip to main content

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 [`Auth`], so [`Auth`]
16//! and [`HttpClientConfig`] debug output redacts bearer tokens, basic passwords, and API-key values.
17//! Prefer [`HttpClientConfig::with_auth`] or request auth helpers over raw credential headers.
18//!
19//! # Example
20//!
21//! ```no_run
22//! use rskit_httpclient::{HttpClient, HttpClientConfig, Request};
23//!
24//! #[tokio::main]
25//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
26//!     let config = HttpClientConfig::new()
27//!         .with_base_url("https://api.example.com")
28//!         .with_user_agent("my-app/1.0");
29//!
30//!     let client = HttpClient::new(config)?;
31//!
32//!     // Simple GET request
33//!     let resp = client.get("/users").await?;
34//!     let text = resp.text()?;
35//!     println!("{}", text);
36//!
37//!     // GET request with bearer token
38//!     let resp = client.send(
39//!         Request::get("/protected")
40//!             .bearer_token("secret-token")
41//!     ).await?;
42//!
43//!     // POST request with JSON
44//!     let body = serde_json::json!({"name": "Alice"});
45//!     let resp = client.post("/users", &body).await?;
46//!
47//!     Ok(())
48//! }
49//! ```
50
51pub mod auth;
52pub mod client;
53pub mod config;
54pub mod destination;
55pub mod request;
56pub mod response;
57
58mod tls;
59mod transport;
60
61pub use auth::Auth;
62pub use client::HttpClient;
63pub use config::HttpClientConfig;
64pub use destination::DestinationPolicy;
65pub use request::{Request, RequestBody};
66pub use response::{ErrorResponse, Response};