pub struct ServerConfig {
pub env: AppEnv,
pub http_addr: SocketAddr,
pub expose_error_details: bool,
pub security: HttpSecurity,
pub oidc: Option<OidcConfig>,
}Expand description
The runtime configuration of a Seiva service, read from the environment.
It is small but real. Build it with from_process_env
(the 12-factor path) or, in tests, with seiva_config::load_from over an
explicit map (deterministic, never racing on the process-global environment).
§HTTP address precedence
The bind address is resolved in this order, highest first:
SEIVA_HTTP_ADDR— a fullhost:port(e.g.0.0.0.0:8080). Wins whenever it is set.PORT— a bare port, the convention hosting platforms set. Bound on0.0.0.0(all interfaces), since a platform that setsPORTroutes external traffic to the container.DEFAULT_HTTP_ADDR—127.0.0.1:8080, loopback only.
§Production-safety guard
EXPOSE_ERROR_DETAILS_VAR is a development convenience. Through
AppEnv::reject_dev_shortcut it is a startup error to enable it when
APP_ENV=production, so the mistake fails the boot rather than leaking
internals on the first error in production.
Fields§
§env: AppEnvThe runtime environment (APP_ENV), defaulting to
Development.
http_addr: SocketAddrThe resolved HTTP bind address (see the precedence on ServerConfig).
expose_error_details: boolWhether internal error details are exposed to clients. A development-only shortcut, refused in production by the guard.
security: HttpSecurityThe transport-level security posture (HttpSecurity) read from the
environment: the CORS allowlist, the trusted-proxy switch and the rate
limit. Default (same-origin only, rate limiting
on) when none of the variables are set.
oidc: Option<OidcConfig>The OIDC/JWT authentication configuration, or None when the
SEIVA_OIDC_* variables are unset (no authn layer — every caller
anonymous). Built into a JwtAuthenticator at serve time.
Implementations§
Source§impl ServerConfig
impl ServerConfig
Sourcepub fn from_process_env() -> Result<Self, ConfigError>
pub fn from_process_env() -> Result<Self, ConfigError>
Loads and validates the configuration from the live process environment.
This is what a main calls: on success it holds a fully typed, fully
validated configuration; on failure every problem is reported together.
§Errors
Returns a ConfigError when APP_ENV is unrecognised, when an address
variable fails to parse, or when the production guard rejects a dev
shortcut.
Sourcepub fn default_http_addr() -> SocketAddr
pub fn default_http_addr() -> SocketAddr
The DEFAULT_HTTP_ADDR parsed into a SocketAddr.