pub struct Config {
pub url: Option<String>,
pub provider: CdnProvider,
pub purge_token: Option<String>,
pub purge_zone: Option<String>,
pub provider_error: Option<String>,
}Expand description
Provider-agnostic CDN configuration. Read via Config::from_env;
build the active purge adapter with Config::build_purge_api.
§Token security
purge_token is never logged. Debug prints <redacted> for it.
Fields§
§url: Option<String>CDN base URL fronting the bucket (CDN_URL). Drives Disk::cdn_url().
provider: CdnProviderSelected provider for cache invalidation (CDN_PROVIDER).
purge_token: Option<String>Provider API credential (CDN_PURGE_TOKEN). Never logged.
purge_zone: Option<String>Provider-specific zone or endpoint id (CDN_PURGE_ZONE).
provider_error: Option<String>Set when CDN_PROVIDER is explicitly provided but fails to parse.
build_purge_api converts this into a boot Error (D-03 / SC-5b).
Implementations§
Source§impl Config
impl Config
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
Read CDN config from environment: the quartet primary + per-var legacy fallbacks.
Provider resolution runs first; token/zone aliases are then scoped to the resolved provider so that a stray credential from a different provider’s legacy cluster cannot win the fallback race.
If CDN_PROVIDER is set to an unrecognized value the struct is returned with
provider_error set; the parse failure is surfaced as a boot Error by
Config::build_purge_api.
Sourcepub fn build_purge_api(&self) -> Result<Option<Box<dyn PurgeApi>>, Error>
pub fn build_purge_api(&self) -> Result<Option<Box<dyn PurgeApi>>, Error>
Build the active purge adapter, or Ok(None) for provider None.
Returns Err(CdnInvalidProvider) when CDN_PROVIDER was set to an unrecognized
value during from_env (D-03 boot error, SC-5b).
Returns Err(CdnFeatureRequired) if the selected provider’s cargo feature is off.