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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user