pub struct Config {
pub admin: AdminConfig,
pub body_limits: BodyLimitsConfig,
pub clusters: Vec<Cluster>,
pub filter_chains: Vec<FilterChainConfig>,
pub insecure_options: InsecureOptions,
pub listeners: Vec<Listener>,
pub runtime: RuntimeConfig,
pub shutdown_timeout_secs: u64,
}Expand description
Top-level proxy configuration.
use praxis_core::config::Config;
let config = Config::from_yaml(
r#"
listeners:
- name: web
address: "127.0.0.1:8080"
filter_chains: [main]
filter_chains:
- name: main
filters:
- filter: static_response
status: 200
"#,
)
.unwrap();
assert_eq!(config.listeners[0].address, "127.0.0.1:8080");Fields§
§admin: AdminConfigAdmin endpoint settings (address and verbosity).
body_limits: BodyLimitsConfigGlobal hard ceilings on request and response body size.
clusters: Vec<Cluster>Cluster definitions referenced by filters.
filter_chains: Vec<FilterChainConfig>Named filter chains.
insecure_options: InsecureOptionsConsolidated security overrides. All default to false.
listeners: Vec<Listener>Proxy listeners to bind.
runtime: RuntimeConfigRuntime configuration knobs.
shutdown_timeout_secs: u64Drain time for graceful shutdown.
Implementations§
Source§impl Config
impl Config
Sourcepub fn validate(&mut self) -> Result<(), ProxyError>
pub fn validate(&mut self) -> Result<(), ProxyError>
Validate config constraints.
§Errors
Returns ProxyError::Config if any constraint is violated.
use praxis_core::config::Config;
let err = Config::from_yaml("listeners: []\n").unwrap_err();
assert!(err.to_string().contains("at least one listener"));Source§impl Config
impl Config
Sourcepub fn from_yaml(s: &str) -> Result<Self, ProxyError>
pub fn from_yaml(s: &str) -> Result<Self, ProxyError>
Parse config from a YAML string.
§Errors
Returns ProxyError::Config if the YAML is invalid, oversized, or fails validation.
§Security: Error Messages
Parse errors from serde_yaml may include context snippets from the input YAML.
This is acceptable for server-side operator tooling but callers should avoid
exposing these errors to untrusted end users.
use praxis_core::config::Config;
let cfg = Config::from_yaml(
r#"
listeners:
- name: web
address: "127.0.0.1:8080"
filter_chains: [main]
filter_chains:
- name: main
filters:
- filter: static_response
status: 200
"#,
)
.unwrap();
assert_eq!(cfg.listeners[0].address, "127.0.0.1:8080");Sourcepub fn from_file(path: &Path) -> Result<Self, ProxyError>
pub fn from_file(path: &Path) -> Result<Self, ProxyError>
Load and validate config from a YAML file.
§Errors
Returns ProxyError::Config if the file cannot be read or contains invalid config.
use std::path::Path;
use praxis_core::config::Config;
let cfg = Config::from_file(Path::new("praxis.yaml")).unwrap();
println!("listeners: {}", cfg.listeners.len());Sourcepub fn load(
explicit_path: Option<&str>,
fallback_yaml: &str,
) -> Result<Self, ProxyError>
pub fn load( explicit_path: Option<&str>, fallback_yaml: &str, ) -> Result<Self, ProxyError>
Resolve configuration file. Fall back to praxis.yaml in the working directory, then fallback_yaml.
§Errors
Returns ProxyError::Config if the resolved config source cannot be loaded or is invalid.
use praxis_core::config::Config;
let yaml = "listeners: [{name: w, address: '0:80'}]";
let cfg = Config::load(None, yaml).unwrap();