Skip to main content

Mountain/Cache/AssetMemoryMap/
MimeFromExtension.rs

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