Crate foxy

Source
Expand description

Foxy - A zero-config, configuration-driven HTTP proxy library

Foxy offers a minimal attack-surface out of the box – it does nothing but forward HTTP/1.1 requests until you deliberately opt-in to extra behaviour via configuration files or extension traits.

§Quick-start

cargo add foxy-io
use foxy::{Foxy};
use std::error::Error;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
     
    let foxy = Foxy::loader()
        .with_config_file("config.json")
        .build().await?;

    foxy.start().await?;
    Ok(())
}

§Feature flags

featuredefaultdescription
yamlEnables YAML configuration alongside TOML/JSON
opentelemetryEnables OpenTelemetry tracing integration

§Extension points

  • ConfigProvider – plug in an arbitrary configuration backend
  • Filter – inject pre/post processing stages
  • Predicate – custom routing logic

See the examples directory for a working proxy with logging & path-rewrite.

Re-exports§

pub use config::ConfigProvider;
pub use config::ConfigProviderExt;
pub use config::ConfigError;
pub use loader::Foxy;
pub use loader::FoxyLoader;
pub use loader::LoaderError;
pub use core::Filter;
pub use core::FilterType;
pub use core::Router;
pub use core::Route;
pub use core::ProxyRequest;
pub use core::ProxyResponse;
pub use core::ProxyError;
pub use core::RequestContext;
pub use core::ResponseContext;
pub use core::HttpMethod;
pub use router::PredicateRouter;
pub use router::Predicate;
pub use router::PredicateFactory;
pub use router::PathPredicate;
pub use router::MethodPredicate;
pub use router::HeaderPredicate;
pub use router::QueryPredicate;
pub use filters::LoggingFilter;
pub use filters::HeaderFilter;
pub use filters::TimeoutFilter;
pub use filters::FilterFactory;
pub use filters::PathRewriteFilter;
pub use filters::PathRewriteFilterConfig;
pub use security::SecurityProvider;
pub use security::SecurityStage;
pub use security::SecurityChain;
pub use security::oidc::OidcProvider;
pub use security::oidc::OidcConfig;
pub use server::ProxyServer;
pub use server::ServerConfig;
pub use logging::init as init_logging;
pub use logging::log_error;
pub use logging::log_warning;
pub use logging::log_debug;
pub use logging::log_trace;
pub use logging::log_info;

Modules§

config
Foxy configuration subsystem
core
Core primitives – requests, responses, filters & routing.
filters
Built-in filters
loader
High-level entry-point – “turn the key and go”.
logging
Logging utilities for Foxy.
router
Routing DSL – predicates & helper logic.
security
Security subsystem – runs before/after the main filter pipeline.
server
HTTP server implementation for Foxy.