pub struct ServerConfig {Show 19 fields
pub bind: String,
pub server_name: Vec<String>,
pub tls: Option<TlsConfig>,
pub redirect_http: Option<RedirectHttpConfig>,
pub hsts: HstsConfig,
pub limits: LimitsConfig,
pub compression: CompressionConfig,
pub static_files: BTreeMap<String, StaticMount>,
pub rate_limit: RateLimitConfig,
pub trusted_proxies: TrustedProxiesConfig,
pub route_timeouts: Vec<RouteTimeoutRule>,
pub access_log: AccessLogConfig,
pub rewrites: Vec<RewriteRule>,
pub error_pages: BTreeMap<String, PathBuf>,
pub trailing_slash: TrailingSlashConfig,
pub proxies: Vec<ProxyRule>,
pub cors: CorsConfig,
pub ip_rules: Vec<IpRule>,
pub basic_auth: Vec<BasicAuthRule>,
}Fields§
§bind: StringBind address. Default: 127.0.0.1:8080 (set in from_env).
server_name: Vec<String>Virtual host names this server answers to. Empty = match all hosts.
Supports wildcard prefixes: "*.example.com" matches any subdomain.
tls: Option<TlsConfig>Optional TLS config. If present, the server runs HTTPS.
redirect_http: Option<RedirectHttpConfig>Optional HTTP-to-HTTPS auto-redirect listener. Typically binds :80 and
301-redirects every request to the equivalent https:// URL.
hsts: HstsConfigHTTP Strict Transport Security (HSTS) header. Off by default.
limits: LimitsConfigBody/timeout limits.
compression: CompressionConfigCompression layer config.
static_files: BTreeMap<String, StaticMount>Static file mounts — map of URL prefix → on-disk dir + cache policy.
rate_limit: RateLimitConfigRate limiting rules.
trusted_proxies: TrustedProxiesConfigTrusted reverse-proxy ranges. Forwarded headers from outside these CIDRs are ignored.
route_timeouts: Vec<RouteTimeoutRule>Per-route timeout overrides. Each entry matches by path prefix and
applies its own timeout to requests under that prefix, overriding
limits.request_timeout. First matching prefix wins. Useful for
slow endpoints (large uploads, long polls) that don’t want the
global timeout raised.
access_log: AccessLogConfigAccess log config.
rewrites: Vec<RewriteRule>URL rewrite rules (regex from → to, optionally as a redirect).
error_pages: BTreeMap<String, PathBuf>Custom error pages — map of status code (as a string key) → file path.
trailing_slash: TrailingSlashConfigTrailing-slash policy.
proxies: Vec<ProxyRule>Reverse-proxy rules — path prefix → upstream URL.
cors: CorsConfigCORS configuration.
ip_rules: Vec<IpRule>Path-prefixed IP allow/deny rules.
basic_auth: Vec<BasicAuthRule>Path-prefixed HTTP Basic Auth blocks.
Implementations§
Source§impl ServerConfig
impl ServerConfig
Sourcepub fn from_file_or_default(path: impl AsRef<Path>) -> Self
pub fn from_file_or_default(path: impl AsRef<Path>) -> Self
Load from config/anvil.toml if present, otherwise return defaults.
pub fn from_file(path: &Path) -> Result<Self>
Sourcepub fn apply_env_overrides(self) -> Self
pub fn apply_env_overrides(self) -> Self
Apply env-var overrides for the most common keys, mirroring Laravel’s
config(...) + .env precedence.
Trait Implementations§
Source§impl Clone for ServerConfig
impl Clone for ServerConfig
Source§fn clone(&self) -> ServerConfig
fn clone(&self) -> ServerConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ServerConfig
impl Debug for ServerConfig
Source§impl Default for ServerConfig
impl Default for ServerConfig
Source§fn default() -> ServerConfig
fn default() -> ServerConfig
Source§impl<'de> Deserialize<'de> for ServerConfigwhere
ServerConfig: Default,
impl<'de> Deserialize<'de> for ServerConfigwhere
ServerConfig: Default,
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 ServerConfig
impl RefUnwindSafe for ServerConfig
impl Send for ServerConfig
impl Sync for ServerConfig
impl Unpin for ServerConfig
impl UnsafeUnpin for ServerConfig
impl UnwindSafe for ServerConfig
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,
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