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