bws_web_server/
lib.rs

1pub mod config;
2pub mod handlers;
3pub mod server;
4pub mod ssl;
5
6// Re-export main types for convenience
7pub use config::{ServerConfig, SiteConfig};
8pub use server::WebServerService;
9pub use ssl::{AcmeConfig, SslManager};
10
11// Legacy compatibility exports
12use std::fs;
13
14// Legacy function for backward compatibility
15pub fn read_file_bytes(file_path: &str) -> std::io::Result<Vec<u8>> {
16    fs::read(file_path)
17}
18
19// Legacy function for backward compatibility
20pub fn get_mime_type(file_path: &str) -> &'static str {
21    let path = std::path::Path::new(file_path);
22    match path.extension().and_then(|ext| ext.to_str()) {
23        Some("html") | Some("htm") => "text/html",
24        Some("css") => "text/css",
25        Some("js") | Some("mjs") => "application/javascript",
26        Some("json") => "application/json",
27        Some("png") => "image/png",
28        Some("jpg") | Some("jpeg") => "image/jpeg",
29        Some("gif") => "image/gif",
30        Some("svg") => "image/svg+xml",
31        Some("ico") => "image/x-icon",
32        Some("txt") => "text/plain",
33        Some("pdf") => "application/pdf",
34        Some("woff") | Some("woff2") => "font/woff",
35        Some("ttf") => "font/ttf",
36        Some("otf") => "font/otf",
37        Some("eot") => "application/vnd.ms-fontobject",
38        Some("xml") => "application/xml",
39        Some("wasm") => "application/wasm",
40        Some("webp") => "image/webp",
41        Some("avif") => "image/avif",
42        Some("mp4") => "video/mp4",
43        Some("webm") => "video/webm",
44        Some("mp3") => "audio/mpeg",
45        Some("wav") => "audio/wav",
46        Some("ogg") => "audio/ogg",
47        Some("zip") => "application/zip",
48        Some("gz") => "application/gzip",
49        Some("tar") => "application/x-tar",
50        Some("md") => "text/markdown",
51        Some("yaml") | Some("yml") => "application/x-yaml",
52        Some("toml") => "application/toml",
53        _ => "application/octet-stream",
54    }
55}