1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//! Tiny Proxy Server - Embeddable HTTP Reverse Proxy
//!
//! This library provides a lightweight, configurable HTTP reverse proxy
//! that can be embedded into Rust applications or run as a standalone CLI tool.
//!
//! ## Features
//!
//! - Configuration via Caddy-like syntax
//! - Path-based routing with pattern matching
//! - Header manipulation
//! - URI rewriting
//! - HTTP/HTTPS backend support
//!
//! ## Example (Library Mode)
//!
//! ```no_run
//! use tiny_proxy::{Config, Proxy};
//!
//! #[tokio::main]
//! async fn main() -> anyhow::Result<()> {
//! // Load configuration from file
//! let config = Config::from_file("config.caddy")?;
//!
//! // Create and start proxy
//! let proxy = Proxy::new(config);
//! proxy.start("127.0.0.1:8080").await?;
//!
//! Ok(())
//! }
//! ```
//!
//! ## Example (Background Execution)
//!
//! To run the proxy in the background while doing other work:
//!
//! ```no_run
//! use tiny_proxy::{Config, Proxy};
//!
//! #[tokio::main]
//! async fn main() -> anyhow::Result<()> {
//! let config = Config::from_file("config.caddy")?;
//! let proxy = Proxy::new(config);
//!
//! // Spawn proxy in background
//! let handle = tokio::spawn(async move {
//! if let Err(e) = proxy.start("127.0.0.1:8080").await {
//! eprintln!("Proxy error: {}", e);
//! }
//! });
//!
//! // Do other work here...
//!
//! handle.await?;
//! Ok(())
//! }
//! ```
//!
//! ## Example (CLI Mode)
//!
//! When built as a binary, the proxy can be run from command line:
//!
//! ```bash
//! tiny-proxy --config config.caddy --addr 127.0.0.1:8080
//! ```
//!
//! ## Configuration Format
//!
//! The proxy uses a Caddy-like configuration format:
//!
//! ```text
//! localhost:8080 {
//! reverse_proxy backend:3000
//! header X-Forwarded-For {remote_ip}
//! }
//! ```
//!
//! For more configuration options, see the [config] module documentation.
// Re-export commonly used types for convenience
pub use Config;
pub use ;
pub use ;
pub use start_api_server;