pub struct Config {
pub addr: SocketAddr,
pub database_url: String,
pub agents: String,
pub max_batch_days: usize,
pub max_body_bytes: usize,
pub admin: String,
pub admin_email: String,
pub secure_cookies: bool,
pub demo: bool,
pub webhooks: Webhooks,
}Expand description
Runtime configuration, read from the environment.
Fields§
§addr: SocketAddrAddress the HTTP server binds to (KASL_SERVER_ADDR).
database_url: StringPostgreSQL connection string (DATABASE_URL).
agents: StringAgents to provision on startup (KASL_AGENTS), as email:token pairs.
The bootstrap way in until the admin UI issues tokens.
max_batch_days: usizeDays one batch upload may carry (KASL_MAX_BATCH_DAYS).
max_body_bytes: usizeLargest request body accepted (KASL_MAX_BODY_BYTES).
admin: StringBootstrap administrator (KASL_ADMIN), as email:password.
admin_email: StringEmail for the administrator generated on a first run (KASL_ADMIN_EMAIL).
Only used when KASL_ADMIN is unset and the installation has no
administrator at all: the server makes one with a random password and
prints it once. The default is deliberately obvious rather than clever -
an operator who never sets this should still recognize the account.
Whether session cookies carry Secure (KASL_SECURE_COOKIES).
On by default, because a server holding a team’s hours belongs behind
TLS. Turned off only for a stand reached over plain http, where a
Secure cookie is dropped by the browser and login silently does
nothing at all.
demo: boolWhether to seed a fictional team on an empty database (KASL_DEMO).
Off by default. On, the server fills an empty database with the demo team and refuses to start on one that holds anybody real (ADR 0013).
webhooks: WebhooksWhere events are sent (KASL_WEBHOOK_<NAME>, one variable each), and
the address messages link back to (KASL_PUBLIC_URL). Read from the
environment and never from the database: a hook is a credential
(ADR 0019).
Implementations§
Source§impl Config
impl Config
pub fn from_env() -> Result<Self>
Sourcepub fn defaults_for_database(database_url: String) -> Self
pub fn defaults_for_database(database_url: String) -> Self
A configuration with every limit at its default. Used where the limits are not the subject - the router built for tests, for instance - so the defaults live in one place rather than being restated.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnsafeUnpin for Config
impl UnwindSafe for Config
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<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 more