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
// 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.
//!
//!
//! # Routing and Filtering
//!
//! Foxy uses a configuration-driven approach for routing and filtering.
//!
//! # 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 ;