Skip to content

Commit ceca920

Browse files
committed
fix invalid mime types
1 parent 2d7d258 commit ceca920

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/webserver/static_content.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ use actix_web::{
55
};
66

77
macro_rules! static_file_endpoint {
8-
($filestem:literal, $extension:literal) => {{
8+
($filestem:literal, $extension:literal, $mime:literal) => {{
99
const FILENAME_WITH_TAG: &str = static_filename!(concat!($filestem, ".", $extension));
1010
web::resource(FILENAME_WITH_TAG).to(|req: HttpRequest| async move {
1111
let file_etag = EntityTag::new_strong(FILENAME_WITH_TAG.to_string());
1212
if matches!(IfNoneMatch::parse(&req), Ok(IfNoneMatch::Items(etags)) if etags.iter().any(|etag| etag.weak_eq(&file_etag))) {
1313
return HttpResponse::NotModified().finish();
1414
}
1515
HttpResponse::Ok()
16-
.content_type(concat!("text/", $extension, ";charset=UTF-8"))
16+
.content_type(concat!($mime, ";charset=UTF-8"))
1717
.insert_header(CacheControl(vec![
1818
CacheDirective::Public,
1919
CacheDirective::MaxAge(3600 * 24 * 7),
@@ -28,9 +28,9 @@ macro_rules! static_file_endpoint {
2828
}
2929

3030
pub fn js() -> Resource {
31-
static_file_endpoint!("sqlpage", "js")
31+
static_file_endpoint!("sqlpage", "js", "application/javascript")
3232
}
3333

3434
pub fn css() -> Resource {
35-
static_file_endpoint!("sqlpage", "css")
35+
static_file_endpoint!("sqlpage", "css", "text/css")
3636
}

0 commit comments

Comments
 (0)