Implement host-based routing with global routing table

Add routing table (HashMap<String, SiteConfig>) to DynamicConfig for
O(1) host lookup. Implement normalize_host (lowercase + strip port)
per RFC 7230 §2.7.3. Add proxy_handler that routes /health to 200,
missing Host to 400, unknown host to 404, and known host to 200.
Routing table updates atomically via ArcSwap.
This commit is contained in:
2026-06-11 12:57:31 +00:00
parent 994ce0fb66
commit d5f5713deb
6 changed files with 413 additions and 23 deletions

View File

@@ -335,22 +335,22 @@ mod tests {
}
fn valid_dynamic_config() -> DynamicConfig {
DynamicConfig {
sites: vec![SiteConfig {
DynamicConfig::from_sites(
vec![SiteConfig {
host: "test.local".to_string(),
upstream: "127.0.0.1:8080".to_string(),
upstream_scheme: "http".to_string(),
upstream_connect_timeout_secs: 5,
upstream_request_timeout_secs: 60,
}],
rate_limit: RateLimitConfig {
RateLimitConfig {
requests_per_second: 10,
burst: 20,
},
body: BodyConfig {
BodyConfig {
limit_bytes: 104857600,
},
}
)
}
fn make_static_with_sites(sites: Vec<SiteConfig>, tls: TlsConfig) -> StaticConfig {