| Crates.io | bluenote |
| lib.rs | bluenote |
| version | 0.1.0 |
| created_at | 2025-07-20 02:22:03.653998+00 |
| updated_at | 2025-07-20 02:22:03.653998+00 |
| description | Profile-based HTTP client library with configuration management |
| homepage | https://github.com/samwisely75/bluenote |
| repository | https://github.com/samwisely75/bluenote |
| max_upload_size | |
| id | 1760685 |
| size | 129,715 |
A flexible HTTP client library with profile-based configuration support for Rust.
Add this to your Cargo.toml:
[dependencies]
bluenote = { version = "0.1.0", features = ["ini-profiles"] }
use bluenote::{HttpClient, IniProfileStore, HttpRequestArgs, UrlPath};
use std::collections::HashMap;
// Define your request
struct MyRequest {
method: String,
path: UrlPath,
body: Option<String>,
headers: HashMap<String, String>,
}
impl HttpRequestArgs for MyRequest {
fn method(&self) -> Option<&String> { Some(&self.method) }
fn url_path(&self) -> Option<&UrlPath> { Some(&self.path) }
fn body(&self) -> Option<&String> { self.body.as_ref() }
fn headers(&self) -> &HashMap<String, String> { &self.headers }
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Load a profile from an INI file
let store = IniProfileStore::new("profiles.ini");
let profile = store.get_profile("api")?.unwrap();
// Create HTTP client with the profile
let client = HttpClient::new(&profile)?;
// Create your request
let request = MyRequest {
method: "GET".to_string(),
path: UrlPath::new("/users"),
body: None,
headers: HashMap::new(),
};
// Make the request
let response = client.request(&request).await?;
println!("Status: {}", response.status());
println!("Body: {}", response.body());
Ok(())
}
Create a profiles.ini file:
[api]
host = https://api.example.com
@content-type = application/json
@accept = application/json
@authorization = Bearer your-token-here
[local]
host = http://localhost:8080
@content-type = application/json
insecure = true
[staging]
host = https://staging-api.example.com
user = username
password = secret
ca_cert = /path/to/cert.pem
proxy = http://proxy.company.com:8080
Profile settings support:
host, insecure, ca_cert, proxyuser, password (for Basic Auth)@ (e.g., @authorization, @content-type)insecure = true to skip certificate verificationproxy = http://proxy-server:portHttpConnectionProfile: Defines connection settings (host, auth, TLS, proxy)HttpRequestArgs: Defines request parameters (method, URL, body, headers)HttpClient: The main HTTP client for making requestsHttpResponse: Response object with status, headers, and bodyIniProfile: Profile implementation for INI-based configurationIniProfileStore: Manager for loading profiles from INI filesEndpoint: Represents a server endpoint (scheme, host, port)Url: Complete URL with endpoint and pathUrlPath: URL path component with query parametersThe library automatically handles:
ini-profiles (default): Enable INI file profile supportjson-profiles: Enable JSON profile configuration (future feature)Licensed under the Elastic License 2.0. See LICENSE file for details.
This library is extracted from the blueline HTTP client project. Contributions are welcome! Please open issues and pull requests on the main repository.