Skip to main content

Mountain/Cache/AssetMemoryMap/
MimeFromExtension.rs

1
2//! Map a file extension to its IANA media type. Mirrors the inline helper in
3//! `Binary/Build/Scheme.rs` so the cache layer is self-contained.
4
5use std::path::Path;
6
7pub fn Fn(Path:&Path) -> &'static str {
8	match Path.extension().and_then(|S| S.to_str()).unwrap_or("") {
9		"js" | "mjs" | "cjs" => "application/javascript; charset=utf-8",
10
11		"css" => "text/css; charset=utf-8",
12
13		"html" | "htm" => "text/html; charset=utf-8",
14
15		"json" | "map" => "application/json; charset=utf-8",
16
17		"svg" => "image/svg+xml",
18
19		"png" => "image/png",
20
21		"jpg" | "jpeg" => "image/jpeg",
22
23		"gif" => "image/gif",
24
25		"webp" => "image/webp",
26
27		"woff" => "font/woff",
28
29		"woff2" => "font/woff2",
30
31		"ttf" => "font/ttf",
32
33		"otf" => "font/otf",
34
35		"wasm" => "application/wasm",
36
37		"ico" => "image/x-icon",
38
39		"txt" => "text/plain; charset=utf-8",
40
41		"md" => "text/markdown; charset=utf-8",
42
43		_ => "application/octet-stream",
44	}
45}