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//! | `opentelemetry` | ❌ | Enables OpenTelemetry tracing integration |
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// Module declarations
44pub mod config;
45pub mod core;
46pub mod filters;
47pub mod loader;
48pub mod logging;
49pub mod opentelemetry;
50pub mod router;
51pub mod security;
52pub mod server;
53
54// Re-export key types at the crate root for convenience
55pub use crate::opentelemetry::init;
56pub use config::{ConfigError, ConfigProvider, ConfigProviderExt};
57pub use core::{
58 Filter, FilterType, HttpMethod, ProxyError, ProxyRequest, ProxyResponse, RequestContext,
59 ResponseContext, Route, Router,
60};
61pub use filters::{
62 FilterFactory, HeaderFilter, LoggingFilter, PathRewriteFilter, PathRewriteFilterConfig,
63 TimeoutFilter, register_filter,
64};
65pub use loader::{Foxy, FoxyLoader, LoaderError};
66pub use logging::{init_with_config, wrapper};
67pub use router::{
68 HeaderPredicate, MethodPredicate, PathPredicate, Predicate, PredicateFactory, PredicateRouter,
69 QueryPredicate, register_predicate,
70};
71pub use security::{
72 SecurityChain, SecurityProvider, SecurityStage,
73 oidc::{OidcConfig, OidcProvider},
74 register_security_provider,
75};
76pub use server::{ProxyServer, ServerConfig};
77#[cfg(feature = "swagger-ui")]
78pub use server::swagger::{SwaggerSource, SwaggerUIConfig};