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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
//! Foxy - A minimal, configuration-driven, hyper-extendible Rust HTTP proxy library
//!
//! Foxy is designed as a drop-in component with configurable behavior. By default,
//! it provides only basic pass-through routing, with all other functionality
//! requiring explicit opt-in via configuration or code extension.
//!
//! # Core Principles
//!
//! - **Security**: Secure core routing with no features enabled by default
//! - **Extensibility**: Design around traits for user extensions
//! - **Configuration**: Drive all non-default behavior via configuration
//! - **Minimal Default**: "Zero-config" results in only basic request forwarding
//!
//! # Configuration System
//!
//! Foxy's configuration system is built for flexibility and extensibility:
//!
//! - **Multiple Configuration Sources**: Load configuration from files (JSON, TOML, YAML)
//! and environment variables.
//! - **Layered Configuration**: Create a hierarchy of configuration providers with
//! well-defined priorities.
//! - **Type Safety**: Parse configuration values into the appropriate Rust types.
//! - **Extensibility**: Implement the `ConfigProvider` trait to create custom configuration sources.
//!
//! # Initialization and Usage
//!
//! Foxy is initialized using the `Foxy` loader, which provides a fluent API for configuration:
//!
//! ```rust,no_run
//! use foxy::Foxy;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Initialize with default settings
//! let foxy = Foxy::loader().build()?;
//!
//! // Or with custom configuration
//! let custom_foxy = Foxy::loader()
//! .with_config_file("config.toml")
//! .with_env_vars()
//! .build()?;
//!
//! // Start the proxy server
//! foxy.start().await?;
//!
//! Ok(())
//! }
//! ```
//!
//! # Routing and Filtering
//!
//! Foxy uses a configuration-driven approach for routing and filtering:
//!
//! ```json
//! {
//! "routes": [
//! {
//! "id": "api",
//! "target": "http://api-backend.com",
//! "path": "/api/*",
//! "filters": ["logging", "header"],
//! "priority": 10
//! }
//! ],
//! "filters": {
//! "logging": {
//! "type": "logging",
//! "config": {
//! "log_request_headers": true,
//! "log_request_body": false,
//! "log_level": "debug"
//! }
//! },
//! "header": {
//! "type": "header",
//! "config": {
//! "add_request_headers": {
//! "X-Proxy-Version": "Foxy/0.1.0"
//! }
//! }
//! }
//! }
//! }
//! ```
//!
//! # Custom Filters
//!
//! You can implement custom filters by implementing the `Filter` trait:
//!
//! ```rust,no_run
//! use async_trait::async_trait;
//! use foxy::{Filter, FilterType, ProxyRequest, ProxyResponse, ProxyError};
//!
//! #[derive(Debug)]
//! struct MyCustomFilter;
//!
//! #[async_trait]
//! impl Filter for MyCustomFilter {
//! fn filter_type(&self) -> FilterType {
//! FilterType::Both
//! }
//!
//! fn name(&self) -> &str {
//! "my_custom_filter"
//! }
//!
//! async fn pre_filter(&self, request: ProxyRequest) -> Result<ProxyRequest, ProxyError> {
//! // Modify the request
//! Ok(request)
//! }
//!
//! async fn post_filter(&self, request: ProxyRequest, response: ProxyResponse) -> Result<ProxyResponse, ProxyError> {
//! // Modify the response
//! Ok(response)
//! }
//! }
//! ```
// Module declarations
// Re-export key types at the crate root for convenience
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;