Expand description
Typed server configuration.
ServerConfig holds all per-instance configuration fields as typed Rust
values. It replaces point-of-use env::var("RWS_CONFIG_*") calls with a
struct that can be:
- Built from environment variables once at startup:
ServerConfig::from_env() - Constructed directly in tests without touching the environment:
ServerConfig::default()/ struct update syntax - Passed to [
App::with_config] to create a fully isolated application instance — essential for parallel tests and embedded multi-tenant use
§Test isolation example
ⓘ
use rust_web_server::app::App;
use rust_web_server::server_config::ServerConfig;
use rust_web_server::test_client::TestClient;
// No env writes, no lock needed.
let app = App::with_config(ServerConfig {
cors_allow_all: false,
cors_allow_origins: "https://example.com".to_string(),
..ServerConfig::default()
});
let client = TestClient::new(app);
let res = client.get("/").send();Structs§
- Server
Config - All runtime-configurable settings for one server instance.