pub struct AppConfig {Show 25 fields
pub env: AppEnv,
pub app_name: String,
pub bind_addr: String,
pub database_url: String,
pub secret_key: String,
pub storage_dir: PathBuf,
pub assets_dir: PathBuf,
pub job_poll_interval_ms: u64,
pub job_concurrency: usize,
pub cookie_secure: bool,
pub webhooks_live: bool,
pub webhooks_allow_local: bool,
pub cors_origins: Vec<String>,
pub trust_proxy: bool,
pub metrics_token: Option<String>,
pub max_body_bytes: usize,
pub max_blob_bytes: usize,
pub csrf_enforce: bool,
pub slow_request_ms: u64,
pub slow_job_ms: u64,
pub git_sha: Option<String>,
pub incident_webhook_url: Option<String>,
pub incident_webhook_secret: Option<String>,
pub bug_reporter_enabled: bool,
pub bug_reporter_allow_anonymous: bool,
}Expand description
Runtime configuration loaded from SLABS_* and DATABASE_URL environment variables.
Fields§
§env: AppEnvDeployment environment (SLABS_ENV, default AppEnv::Development).
app_name: StringApplication name used for default database filenames, storage directories, and manifests.
bind_addr: StringSocket address to bind the HTTP server to (SLABS_BIND, default "127.0.0.1:3000").
database_url: StringConnection string for the primary database (DATABASE_URL, default "sqlite://{app_name}.db?mode=rwc").
secret_key: StringSecret key for signing cookies, tokens, and HMAC digests (SLABS_SECRET_KEY).
storage_dir: PathBufDirectory where uploaded blobs and local storage files are written (SLABS_STORAGE_DIR).
assets_dir: PathBufDirectory containing static assets such as CSS and JS files (SLABS_ASSETS_DIR).
job_poll_interval_ms: u64Polling interval in milliseconds for the background job worker (SLABS_JOB_POLL_MS, default 500).
job_concurrency: usizeMaximum number of background jobs executed concurrently (SLABS_JOB_CONCURRENCY, default 4).
Sets the Secure attribute on session cookies when true (SLABS_COOKIE_SECURE, default env.is_prod_like()).
webhooks_live: boolEnables live HTTP delivery for outbound webhooks when true (SLABS_WEBHOOKS_LIVE, default false).
webhooks_allow_local: boolAllows outbound webhooks to target loopback addresses when true (SLABS_WEBHOOKS_ALLOW_LOCAL, default false).
cors_origins: Vec<String>Allowed CORS origins loaded from comma-separated SLABS_CORS_ORIGINS.
trust_proxy: boolWhether to trust reverse-proxy forwarding headers (SLABS_TRUST_PROXY, default false).
metrics_token: Option<String>Optional bearer token protecting the metrics endpoint (SLABS_METRICS_TOKEN).
max_body_bytes: usizeMaximum HTTP request body size in bytes (SLABS_MAX_BODY_BYTES, default 4 MiB).
max_blob_bytes: usizeMaximum blob upload size in bytes (SLABS_MAX_BLOB_BYTES, default 10 MiB).
csrf_enforce: boolEnforces CSRF checks on cookie-authenticated mutations (SLABS_CSRF_ENFORCE, default true).
slow_request_ms: u64HTTP request latency threshold in milliseconds for slow-request incident capture (SLABS_SLOW_REQUEST_MS, default 500).
slow_job_ms: u64Background job execution latency threshold in milliseconds for slow-job incident capture (SLABS_SLOW_JOB_MS, default 5_000).
git_sha: Option<String>Optional Git commit SHA of the running build attached to runtime incidents (SLABS_GIT_SHA).
incident_webhook_url: Option<String>Optional webhook URL notified when a runtime incident is opened, re-opened, or resolved (SLABS_INCIDENT_WEBHOOK_URL).
incident_webhook_secret: Option<String>Optional HMAC-SHA256 signing secret for Incident Protocol v1 webhooks (SLABS_INCIDENT_WEBHOOK_SECRET).
bug_reporter_enabled: boolEnables the built-in user bug reporter endpoint and widget (SLABS_BUG_REPORTER, defaults to true in development/staging and false in production/test).
bug_reporter_allow_anonymous: boolAllows unauthenticated users to submit bug reports (SLABS_BUG_REPORTER_ANONYMOUS, default false).
Implementations§
Source§impl AppConfig
impl AppConfig
Sourcepub const DEV_SECRET_FALLBACK_SENTINEL: &'static str = "dev-only-change-me-in-production-slabs-secret-key"
pub const DEV_SECRET_FALLBACK_SENTINEL: &'static str = "dev-only-change-me-in-production-slabs-secret-key"
Legacy development fallback secret rejected by AppConfig::validate in staging and production.
Sourcepub fn from_env(app_name: impl Into<String>) -> AppConfig
pub fn from_env(app_name: impl Into<String>) -> AppConfig
Loads configuration from SLABS_* and DATABASE_URL environment variables.
Falls back to local development defaults derived from app_name when variables are unset.
When SLABS_SECRET_KEY is unset in development or test, generates a random ephemeral
32-byte hex key and logs a warning; in staging or production it leaves secret_key empty
so AppConfig::validate fails closed.
Sourcepub fn for_test(app_name: impl Into<String>, storage_dir: PathBuf) -> AppConfig
pub fn for_test(app_name: impl Into<String>, storage_dir: PathBuf) -> AppConfig
Builds an isolated configuration for parallel tests.
Uses env = AppEnv::Test, database_url = "sqlite::memory:", bind_addr = "127.0.0.1:0",
a 50ms job poll interval, and disables cookie_secure, webhooks_live, and webhooks_allow_local.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for AppConfig
impl<'de> Deserialize<'de> for AppConfig
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<AppConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<AppConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for AppConfig
impl Serialize for AppConfig
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Forget for AppConfig
impl Freeze for AppConfig
impl Move for AppConfig
impl RefUnwindSafe for AppConfig
impl Send for AppConfigwhere
RawVecInner: Send,
impl Sync for AppConfigwhere
RawVecInner: Sync,
impl Unpin for AppConfig
impl UnsafeUnpin for AppConfigwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
impl UnwindSafe for AppConfigwhere
RawVecInner: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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>,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ServiceExt for T
impl<T> ServiceExt for T
Source§fn compression(self) -> Compression<Self>where
Self: Sized,
fn compression(self) -> Compression<Self>where
Self: Sized,
Source§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
Source§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
Source§fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
Source§fn override_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn override_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
Source§fn append_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn append_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
Source§fn insert_request_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn insert_request_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
Source§fn override_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn override_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
Source§fn append_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn append_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
Source§fn insert_response_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn insert_response_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
Source§fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
Source§fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
x-request-id as the header name. Read moreSource§fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
Source§fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
x-request-id as the header name. Read moreSource§fn request_body_limit(self, limit: usize) -> RequestBodyLimit<Self>where
Self: Sized,
fn request_body_limit(self, limit: usize) -> RequestBodyLimit<Self>where
Self: Sized,
413 Payload Too Large responses. Read more