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//!
38//! ## Extension points
39//! * `ConfigProvider` – plug in an arbitrary configuration backend
40//! * `Filter` – inject pre/post processing stages
41//! * `Predicate` – custom routing logic
42//!
43//! See the *examples* directory for a working proxy with logging & path-rewrite.
44
45// Module declarations
46pub mod config;
47pub mod loader;
48pub mod core;
49pub mod router;
50pub mod filters;
51pub mod server;
52pub mod security;
53
54// Re-export key types at the crate root for convenience
55pub use config::{ConfigProvider, ConfigProviderExt, ConfigError};
56pub use loader::{Foxy, FoxyLoader, LoaderError};
57pub use core::{
58 Filter, FilterType, Router, Route,
59 ProxyRequest, ProxyResponse, ProxyError,
60 RequestContext, ResponseContext, HttpMethod
61};
62pub use router::{
63 PredicateRouter, Predicate, PredicateFactory,
64 PathPredicate, MethodPredicate, HeaderPredicate, QueryPredicate
65};
66pub use filters::{
67 LoggingFilter, HeaderFilter, TimeoutFilter, FilterFactory,
68 PathRewriteFilter, PathRewriteFilterConfig
69};
70pub use security::{
71 SecurityProvider,
72 SecurityStage,
73 SecurityChain,
74 oidc::{OidcProvider, OidcConfig},
75};
76pub use server::{ProxyServer, ServerConfig};