Initialize Rust project with Cargo, dependencies, and module skeleton
Set up single-binary reverse-proxy project with all core dependencies (axum, tokio, hyper, tower, rustls, tokio-rustls, rustls-acme, serde, toml, arc-swap, tracing, tracing-subscriber, rustls-pemfile, rustls-pki-types, clap, signal-hook, anyhow, thiserror) pinned to exact versions. Create module skeleton (config, proxy, tls, rate_limit, logging, admin, health, shutdown) matching architecture spec.
This commit is contained in:
50
src/config/dynamic_config.rs
Normal file
50
src/config/dynamic_config.rs
Normal file
@@ -0,0 +1,50 @@
|
||||
use serde::Deserialize;
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct DynamicConfig {
|
||||
pub sites: Vec<SiteConfig>,
|
||||
pub rate_limit: RateLimitConfig,
|
||||
pub body: BodyConfig,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct SiteConfig {
|
||||
pub host: String,
|
||||
pub upstream: String,
|
||||
#[serde(default = "default_upstream_scheme")]
|
||||
pub upstream_scheme: String,
|
||||
#[serde(default = "default_connect_timeout")]
|
||||
pub upstream_connect_timeout_secs: u64,
|
||||
#[serde(default = "default_request_timeout")]
|
||||
pub upstream_request_timeout_secs: u64,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn default_upstream_scheme() -> String {
|
||||
"http".to_string()
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn default_connect_timeout() -> u64 {
|
||||
5
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn default_request_timeout() -> u64 {
|
||||
60
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct RateLimitConfig {
|
||||
pub requests_per_second: u32,
|
||||
pub burst: u32,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct BodyConfig {
|
||||
pub limit_bytes: u64,
|
||||
}
|
||||
Reference in New Issue
Block a user