pub struct ServerConfig {
pub root: Option<PathBuf>,
pub server_name: Option<String>,
pub no_server_header: bool,
pub workers: Option<usize>,
pub tls: Option<TlsConfig>,
pub compress: Option<CompressConfig>,
pub allow_http: bool,
pub acme: Option<AcmeFileConfig>,
pub hsts: Option<HstsConfig>,
pub privdrop: Option<PrivDropConfig>,
/* private fields */
}Expand description
The parsed server configuration.
Fields§
§root: Option<PathBuf>Document root for static file serving.
server_name: Option<String>Server header value.
no_server_header: boolOmit the Server response header entirely. Wins over server_name.
workers: Option<usize>Worker thread count (thread-pool runtime).
tls: Option<TlsConfig>TLS settings.
compress: Option<CompressConfig>Compression settings.
allow_http: boolServe content over plain HTTP instead of redirecting to HTTPS.
acme: Option<AcmeFileConfig>Automatic certificate management.
hsts: Option<HstsConfig>Strict-Transport-Security settings (sent on secure responses).
privdrop: Option<PrivDropConfig>Privilege-dropping settings (drop root after binding; Unix only).
Implementations§
Source§impl ServerConfig
impl ServerConfig
Sourcepub fn from_toml_str(s: &str) -> Result<ServerConfig>
pub fn from_toml_str(s: &str) -> Result<ServerConfig>
Parse a configuration from a TOML string.
Sourcepub fn from_file(path: impl AsRef<Path>) -> Result<ServerConfig>
pub fn from_file(path: impl AsRef<Path>) -> Result<ServerConfig>
Read and parse a configuration file.
Sourcepub fn listen_addrs(&self) -> Vec<String>
pub fn listen_addrs(&self) -> Vec<String>
The configured listen addresses, as strings.
Sourcepub fn priv_drop(&self) -> Result<Option<PrivDrop>>
pub fn priv_drop(&self) -> Result<Option<PrivDrop>>
Resolve the [privdrop] table into a runnable
PrivDrop, if configured.
Because dropping privileges is process-wide and must happen only after
every listener (TCP, HTTP redirect, and HTTP/3 UDP) is bound, the actual
drop is performed by the caller (the CLI) — not by
into_server. This exposes the parsed
actions so the binary can apply them once, under the bind-readiness
handshake.
Sourcepub fn into_server(self) -> Result<Server>
pub fn into_server(self) -> Result<Server>
Build a runnable Server from this configuration.
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 more