use crate::stream::StreamConfig;
use std::time::Duration;
#[derive(Debug, Clone)]
pub struct HttpConfig {
pub bind_addr: std::net::SocketAddr,
pub max_connections: usize,
pub buffer_size: usize,
pub read_timeout: Duration,
pub write_timeout: Duration,
pub server_name: Option<String>,
pub echo_headers: bool,
pub default_content_type: Option<String>,
}
impl Default for HttpConfig {
fn default() -> Self {
Self {
bind_addr: "127.0.0.1:8080".parse().unwrap(),
max_connections: 100,
buffer_size: 8192, read_timeout: Duration::from_secs(30),
write_timeout: Duration::from_secs(30),
server_name: Some("EchoServer/1.0".to_string()),
echo_headers: true,
default_content_type: Some("text/plain".to_string()),
}
}
}
impl From<HttpConfig> for StreamConfig {
fn from(config: HttpConfig) -> Self {
Self {
bind_addr: config.bind_addr,
max_connections: config.max_connections,
buffer_size: config.buffer_size,
read_timeout: config.read_timeout,
write_timeout: config.write_timeout,
}
}
}