#[non_exhaustive]pub struct ProxyConfig {Show 21 fields
pub upstream: Option<UpstreamConfig>,
pub descriptors: Vec<DescriptorSource>,
pub listen: ListenConfig,
pub service: ServiceConfig,
pub aliases: Vec<AliasConfig>,
pub openapi: Option<OpenApiConfig>,
pub auth: Option<AuthConfig>,
pub shield: Option<ShieldConfig>,
pub oidc_discovery: Option<OidcDiscoveryConfig>,
pub health: HealthConfig,
pub metrics: MetricsConfig,
pub maintenance: MaintenanceConfig,
pub cors: CorsConfig,
pub logging: LoggingConfig,
pub metrics_classes: Vec<MetricsClassConfig>,
pub forwarded_headers: Vec<String>,
pub streaming: StreamingConfig,
pub concurrency: Option<ConcurrencyConfig>,
pub grpc_web: GrpcWebConfig,
pub transcode: TranscodeConfig,
pub client_address: ClientAddressConfig,
}Expand description
Top-level proxy configuration (loaded from YAML).
Every config type is #[non_exhaustive], so a new setting is not a
breaking change. Build one in code from its Default (or its constructor
when a field has no default) and set the fields you need, or use the
ProxyServer::with_* builder methods.
§Examples
use structured_proxy::config::{DescriptorSource, ProxyConfig, UpstreamConfig};
static DESCRIPTORS: &[u8] = &[];
let mut config = ProxyConfig::default();
config.upstream = Some(UpstreamConfig::new("http://127.0.0.1:50051"));
config.descriptors = vec![DescriptorSource::Embedded { bytes: DESCRIPTORS }];
config.service.name = "embedded".into();
config.validate().unwrap();Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.upstream: Option<UpstreamConfig>The remote gRPC upstream. Required by the standalone proxy and by
ProxyServer::upstream; an embedder
whose upstream is in process
(ProxyServer::service) leaves it out.
descriptors: Vec<DescriptorSource>Proto descriptor sources.
listen: ListenConfigListen addresses.
service: ServiceConfigService identity (for health endpoint, metrics namespace).
aliases: Vec<AliasConfig>Path aliases (e.g., /oauth2/* → /v1/oauth2/*).
openapi: Option<OpenApiConfig>OpenAPI generation.
auth: Option<AuthConfig>Auth configuration (JWT, forward auth, AuthZ).
shield: Option<ShieldConfig>Rate limiting (Shield).
oidc_discovery: Option<OidcDiscoveryConfig>OIDC discovery (optional — for IdP proxies).
health: HealthConfigHealth-probe endpoints (paths configurable; can be disabled).
metrics: MetricsConfigPrometheus metrics endpoint (path configurable; can be disabled).
maintenance: MaintenanceConfigMaintenance mode.
cors: CorsConfigCORS configuration.
logging: LoggingConfigLogging.
metrics_classes: Vec<MetricsClassConfig>Metrics endpoint classification (path patterns → class labels).
forwarded_headers: Vec<String>Headers to forward from HTTP to gRPC metadata. x-forwarded-for,
x-real-ip, forwarded and the headers named in
client_address.forward carry what that forwarding policy wrote,
listed or not.
streaming: StreamingConfigServer-streaming response behavior.
concurrency: Option<ConcurrencyConfig>Request concurrency limit.
grpc_web: GrpcWebConfigHow gRPC-Web calls reach the upstream.
transcode: TranscodeConfigWhich annotated RPCs are transcoded.
client_address: ClientAddressConfigHow the client’s address is resolved: the proxies trusted to report it, and the header they report it in.
Implementations§
Source§impl ProxyConfig
impl ProxyConfig
Sourcepub fn from_yaml_str(yaml: &str) -> Result<Self>
pub fn from_yaml_str(yaml: &str) -> Result<Self>
Parse configuration from a YAML string.
Useful for embedding the proxy: load a baked-in config (e.g. via
include_str!) without touching the filesystem.
Sourcepub fn validate(&self) -> Result<()>
pub fn validate(&self) -> Result<()>
Validate cross-field constraints that the type system can’t express.
Called automatically by from_yaml_str; call it
directly when building a ProxyConfig programmatically so the same
invariants are enforced on the embedded path.
Sourcepub fn parse_rate(rate: &str) -> Option<u32>
pub fn parse_rate(rate: &str) -> Option<u32>
Parse rate string like “20/min” → requests per window.
Trait Implementations§
Source§impl Clone for ProxyConfig
impl Clone for ProxyConfig
Source§impl Debug for ProxyConfig
impl Debug for ProxyConfig
Source§impl Default for ProxyConfig
impl Default for ProxyConfig
Source§impl<'de> Deserialize<'de> for ProxyConfig
impl<'de> Deserialize<'de> for ProxyConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for ProxyConfig
impl RefUnwindSafe for ProxyConfig
impl Send for ProxyConfig
impl Sync for ProxyConfig
impl Unpin for ProxyConfig
impl UnsafeUnpin for ProxyConfig
impl UnwindSafe for ProxyConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request