avx_http/lib.rs
1//! # avx-http - AVL Platform HTTP Client/Server
2//!
3//! Native HTTP library optimized for Brazilian infrastructure and AVL Platform services.
4//!
5//! ## Features
6//!
7//! - **High Performance**: < 500µs request overhead, 100k+ req/s
8//! - **Brazilian Optimized**: Regional routing, smart retries
9//! - **AVL Platform Native**: Built-in auth, telemetry, AvilaDB integration
10//! - **Developer Friendly**: Simple async/await API
11//!
12//! ## Quick Start
13//!
14//! ### Client
15//!
16//! ```rust,no_run
17//! use avx_http::Client;
18//!
19//! #[tokio::main]
20//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
21//! let client = Client::builder()
22//! .build()?;
23//!
24//! let response = client
25//! .get("https://api.avila.cloud/data")
26//! .send()
27//! .await?;
28//!
29//! println!("Status: {}", response.status());
30//! Ok(())
31//! }
32//! ```
33//!
34//! ### Server
35//!
36//! ```rust,no_run
37//! use avx_http::{Server, Router, Response};
38//!
39//! #[tokio::main]
40//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
41//! let router = Router::new()
42//! .get("/", || async { Response::text("Hello!") });
43//!
44//! Server::bind("0.0.0.0:3000")
45//! .router(router)
46//! .run()
47//! .await?;
48//!
49//! Ok(())
50//! }
51//! ```
52
53#![warn(missing_docs)]
54#![warn(clippy::all)]
55
56pub mod error;
57
58#[cfg(feature = "client")]
59pub mod client;
60
61#[cfg(feature = "client")]
62pub mod pool;
63
64#[cfg(feature = "client")]
65pub mod streaming;
66
67#[cfg(feature = "client")]
68pub mod interceptors;
69
70#[cfg(feature = "server")]
71pub mod server;
72
73#[cfg(feature = "server")]
74pub mod middleware;
75
76mod common;
77
78// Re-exports
79pub use error::{Error, Result};
80
81#[cfg(feature = "client")]
82pub use client::{Client, ClientBuilder, Request, Response as ClientResponse};
83
84#[cfg(feature = "client")]
85pub use pool::{ConnectionPool, PoolConfig, PoolStats};
86
87#[cfg(feature = "client")]
88pub use streaming::{StreamingBody, ChunkedEncoder, SseStream};
89
90#[cfg(feature = "client")]
91pub use interceptors::{Interceptors, RequestData, ResponseData, RequestInterceptor, ResponseInterceptor};
92
93#[cfg(feature = "server")]
94pub use server::{Server, Router, Response as ServerResponse};
95
96#[cfg(feature = "server")]
97pub use middleware::{Middleware, Next, Handler, Logger, Cors, RateLimit, Auth};
98
99pub use http::{Method, StatusCode, HeaderMap, HeaderValue, Uri};
100
101/// Library version
102pub const VERSION: &str = env!("CARGO_PKG_VERSION");
103
104#[cfg(test)]
105mod tests {
106 use super::*;
107
108 #[test]
109 fn test_version() {
110 assert!(!VERSION.is_empty());
111 assert!(VERSION.starts_with("0."));
112 }
113}