foxy/lib.rs
1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
5//! Foxy - A zero-config, configuration-*driven* HTTP proxy library
6//!
7//! Foxy offers a *minimal attack-surface* out of the box – it does nothing
8//! but forward HTTP/1.1 requests until you deliberately opt-in to extra
9//! behaviour via **configuration files** or **extension traits**.
10//!
11//! ## Quick-start
12//!
13//! ```bash
14//! cargo add foxy-io
15//! ```
16//!
17//! ```rust,no_run
18//! use foxy::{Foxy};
19//! use std::error::Error;
20//!
21//! #[tokio::main]
22//! async fn main() -> Result<(), Box<dyn Error>> {
23//!
24//! let foxy = Foxy::loader()
25//! .with_config_file("config.json")
26//! .build().await?;
27//!
28//! foxy.start().await?;
29//! Ok(())
30//! }
31//! ```
32//!
33//! ## Feature flags
34//! | feature | default | description |
35//! |---------|---------|-------------|
36//! | `yaml` | ❌ | Enables YAML configuration alongside TOML/JSON |
37//! | `opentelemetry` | ❌ | Enables OpenTelemetry tracing integration |
38//!
39//! ## Extension points
40//! * `ConfigProvider` – plug in an arbitrary configuration backend
41//! * `Filter` – inject pre/post processing stages
42//! * `Predicate` – custom routing logic
43//!
44//! See the *examples* directory for a working proxy with logging & path-rewrite.
45
46// Module declarations
47pub mod config;
48pub mod loader;
49pub mod core;
50pub mod router;
51pub mod filters;
52pub mod server;
53pub mod security;
54pub mod logging;
55
56#[cfg(feature = "opentelemetry")]
57pub mod opentelemetry;
58
59// Re-export key types at the crate root for convenience
60pub use config::{ConfigProvider, ConfigProviderExt, ConfigError};
61pub use loader::{Foxy, FoxyLoader, LoaderError};
62pub use core::{
63 Filter, FilterType, Router, Route,
64 ProxyRequest, ProxyResponse, ProxyError,
65 RequestContext, ResponseContext, HttpMethod
66};
67pub use router::{
68 PredicateRouter, Predicate, PredicateFactory,
69 PathPredicate, MethodPredicate, HeaderPredicate, QueryPredicate
70};
71pub use filters::{
72 LoggingFilter, HeaderFilter, TimeoutFilter, FilterFactory,
73 PathRewriteFilter, PathRewriteFilterConfig
74};
75pub use security::{
76 SecurityProvider,
77 SecurityStage,
78 SecurityChain,
79 oidc::{OidcProvider, OidcConfig},
80};
81pub use server::{ProxyServer, ServerConfig};
82pub use logging::{init as init_logging, log_error, log_warning, log_debug, log_trace, log_info};
83
84#[cfg(feature = "opentelemetry")]
85pub use opentelemetry::{
86 OpenTelemetryFilter, OpenTelemetryConfig, OpenTelemetryFilterFactory,
87 init_opentelemetry, OpenTelemetryError
88};