Skip to content

Commit 9ffd9eb

Browse files
committed
1 parent 48e783f commit 9ffd9eb

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

src/mime/constants.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ utf8_mime_const!(CSS, "CSS", "text", "css");
5757
utf8_mime_const!(HTML, "HTML", "text", "html");
5858
utf8_mime_const!(PLAIN, "Plain text", "text", "plain");
5959
utf8_mime_const!(XML, "XML", "application", "xml");
60+
utf8_mime_const!(RSS, "RSS Feed", "application", "rss+xml");
61+
utf8_mime_const!(ATOM, "Atom Feed", "application", "atom+xml");
6062
mime_const!(ANY, "matching anything", "*", "*");
6163
mime_const!(JSON, "JSON", "application", "json");
6264
mime_const!(SSE, "Server Sent Events", "text", "event-stream");
@@ -72,6 +74,21 @@ mime_const!(JPEG, "JPEG images", "image", "jpeg");
7274
mime_const!(PNG, "PNG images", "image", "png");
7375
mime_const!(SVG, "SVG", "image", "svg+xml");
7476
mime_const!(WEBP, "WebP images", "image", "webp");
77+
78+
// Audio
79+
// https://www.iana.org/assignments/media-types/media-types.xhtml#audio
80+
mime_const!(MIDI, "MIDI audio", "audio", "midi");
81+
mime_const!(MP3, "MPEG audio layer 3", "audio", "mpeg");
82+
mime_const!(OGG, "Ogg vorbis audio", "audio", "ogg");
83+
mime_const!(OPUS, "Opus audio", "audio", "opus");
84+
mime_const!(M4A, "MPEG audio layer 4", "audio", "mp4");
85+
86+
// Video
87+
// https://www.iana.org/assignments/media-types/media-types.xhtml#video
88+
mime_const!(MP4, "MPEG video layer 4", "video", "mp4");
89+
mime_const!(MPEG, "MPEG video", "video", "mpeg");
90+
mime_const!(WEBM, "WebM video", "video", "webm");
91+
mime_const!(AVI, "Microsoft AVI video", "video", "x-msvideo");
7592
// There are multiple `.ico` mime types known, but `image/x-icon`
7693
// is what most browser use. See:
7794
// https://en.wikipedia.org/wiki/ICO_%28file_format%29#MIME_type
@@ -83,3 +100,7 @@ mime_const!(OTF, "OTF", "font", "otf");
83100
mime_const!(TTF, "TTF", "font", "ttf");
84101
mime_const!(WOFF, "WOFF", "font", "woff");
85102
mime_const!(WOFF2, "WOFF2", "font", "woff2");
103+
104+
// Archives
105+
mime_const!(ZIP, "Zip archive", "application", "zip");
106+
mime_const!(SEVENZIP, "7Zip archive", "application", "x-7z-compressed");

src/mime/mod.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,34 @@ impl Mime {
5353
/// Guess the mime type from a file extension
5454
pub fn from_extension(extension: impl AsRef<str>) -> Option<Self> {
5555
match extension.as_ref() {
56+
"7z" => Some(SEVENZIP),
57+
"atom" => Some(ATOM),
58+
"avi" => Some(AVI),
59+
"bin" | "exe" | "dll" | "iso" | "img" => Some(BYTE_STREAM),
5660
"bmp" => Some(BMP),
5761
"css" => Some(CSS),
5862
"html" => Some(HTML),
5963
"ico" => Some(ICO),
6064
"js" | "mjs" | "jsonp" => Some(JAVASCRIPT),
6165
"json" => Some(JSON),
66+
"m4a" => Some(M4A),
67+
"mid" | "midi" | "kar" => Some(MIDI),
68+
"mp3" => Some(MP3),
69+
"mp4" => Some(MP4),
70+
"mpeg" | "mpg" => Some(MPEG),
71+
"ogg" => Some(OGG),
6272
"otf" => Some(OTF),
63-
"svg" => Some(SVG),
73+
"rss" => Some(RSS),
74+
"svg" | "svgz" => Some(SVG),
6475
"ttf" => Some(TTF),
6576
"txt" => Some(PLAIN),
77+
"wasm" => Some(WASM),
78+
"webm" => Some(WEBM),
6679
"webp" => Some(WEBP),
6780
"woff" => Some(WOFF),
6881
"woff2" => Some(WOFF2),
6982
"xml" => Some(XML),
83+
"zip" => Some(ZIP),
7084
_ => None,
7185
}
7286
}

0 commit comments

Comments
 (0)