coman/lib.rs
1//! # Coman - API Collection Manager
2//!
3//! Coman is a library for managing API collections and making HTTP requests.
4//! It can be used as a standalone library or through its CLI interface.
5//!
6//! ## Usage as a Library
7//!
8//! ```rust,no_run
9//! use coman::{CollectionManager, HttpClient, Method};
10//!
11//! #[tokio::main]
12//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
13//! // Create a collection manager with a custom file path
14//! let manager = CollectionManager::new(Some("my-apis.json".to_string()));
15//!
16//! // Add a new collection
17//! manager.add_collection("my-api", "https://api.example.com", vec![])?;
18//!
19//! // Add an endpoint to the collection
20//! manager.add_endpoint(
21//! "my-api",
22//! "get-users",
23//! "/users",
24//! Method::Get,
25//! vec![],
26//! None,
27//! )?;
28//!
29//! // Make an HTTP request using the HttpClient
30//! let client = HttpClient::new();
31//! let response = client
32//! .get("https://api.example.com/users")
33//! .headers(vec![("Authorization".to_string(), "Bearer token".to_string())])
34//! .send()
35//! .await?;
36//!
37//! println!("Status: {}", response.status);
38//! println!("Body: {}", response.body);
39//!
40//! Ok(())
41//! }
42//! ```
43
44pub mod core;
45pub mod helper;
46pub mod models;
47
48// Re-export main types for convenience
49pub use core::collection_manager::CollectionManager;
50pub use core::http_client::{HttpClient, HttpMethod, HttpRequest, HttpResponse};
51pub use models::collection::{Collection, Method, Request};
52
53// CLI module (only available with the cli feature)
54#[cfg(feature = "cli")]
55pub mod cli;