Expand description
§Coman - API Collection Manager
Coman is a library for managing API collections and making HTTP requests. It can be used as a standalone library or through its CLI interface.
§Usage as a Library
use coman::{CollectionManager, HttpClient, Method};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a collection manager with a custom file path
let manager = CollectionManager::new(Some("my-apis.json".to_string()));
// Add a new collection
manager.add_collection("my-api", "https://api.example.com", vec![])?;
// Add an endpoint to the collection
manager.add_endpoint(
"my-api",
"get-users",
"/users",
Method::Get,
vec![],
None,
)?;
// Make an HTTP request using the HttpClient
let client = HttpClient::new();
let response = client
.get("https://api.example.com/users")
.headers(vec![("Authorization".to_string(), "Bearer token".to_string())])
.send()
.await?;
println!("Status: {}", response.status);
println!("Body: {}", response.body);
Ok(())
}Re-exports§
pub use core::collection_manager::CollectionManager;pub use core::http_client::HttpClient;pub use core::http_client::HttpMethod;pub use core::http_client::HttpRequest;pub use core::http_client::HttpResponse;pub use models::collection::Collection;pub use models::collection::Method;pub use models::collection::Request;