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		"css" => "text/css; charset=utf-8",
12		"html" | "htm" => "text/html; charset=utf-8",
13		"json" | "map" => "application/json; charset=utf-8",
14		"svg" => "image/svg+xml",
15		"png" => "image/png",
16		"jpg" | "jpeg" => "image/jpeg",
17		"gif" => "image/gif",
18		"webp" => "image/webp",
19		"woff" => "font/woff",
20		"woff2" => "font/woff2",
21		"ttf" => "font/ttf",
22		"otf" => "font/otf",
23		"wasm" => "application/wasm",
24		"ico" => "image/x-icon",
25		"txt" => "text/plain; charset=utf-8",
26		"md" => "text/markdown; charset=utf-8",
27		_ => "application/octet-stream",
28	}
29}