bitwarden_api_base/configuration.rs
1//! Configuration types for API clients.
2
3use crate::client::new_http_client;
4
5/// Configuration for an API client.
6///
7/// This struct provides all the configuration options needed for making
8/// authenticated HTTP requests to Bitwarden APIs.
9#[derive(Debug, Clone)]
10pub struct Configuration {
11 /// Base URL path for the API (e.g., "<https://api.bitwarden.com>" or "<https://identity.bitwarden.com>").
12 pub base_path: String,
13 /// HTTP client with middleware support.
14 pub client: reqwest_middleware::ClientWithMiddleware,
15}
16
17impl Configuration {
18 /// Build a `Configuration` pointing at `base_path` with a default HTTP client
19 /// configured by [`new_http_client`].
20 pub fn new(base_path: impl Into<String>) -> Self {
21 Self {
22 base_path: base_path.into(),
23 client: new_http_client().into(),
24 }
25 }
26}