feat: 添加图片 Content-Type 支持 (png/jpg/gif/svg/webp)

This commit is contained in:
2026-04-15 13:18:43 +08:00
parent 839e71b28a
commit ef47232b1e

View File

@@ -12,6 +12,11 @@ pub async fn serve_static_files(path: web::Path<String>) -> impl Responder {
Some(file) => {
let content_type = match file_path.split('.').next_back() {
Some("ico") => "image/x-icon",
Some("png") => "image/png",
Some("jpg") | Some("jpeg") => "image/jpeg",
Some("gif") => "image/gif",
Some("svg") => "image/svg+xml",
Some("webp") => "image/webp",
Some("css") => "text/css",
Some("js") => "application/javascript",
Some("html") => "text/html",