char/serve-esm

git clone https://git.t4t.associates/char/serve-esm

Charlotte SomRewrite serve-esm in Rust using Tower and Hypere06f6b7

main
752 B17 linesraw
1pub fn get_mime_type(path: &str) -> Option<&'static str> {
2    let (_, extension) = path.rsplit_once('.')?;
3    Some(match extension.to_ascii_lowercase().as_str() {
4        "js" | "mjs" | "cjs" => "text/javascript; charset=utf-8",
5        "jsx" => "text/jsx; charset=utf-8",
6        "ts" | "mts" | "cts" => "text/typescript; charset=utf-8",
7        "tsx" => "text/tsx; charset=utf-8",
8        "json" | "map" => "application/json; charset=utf-8",
9        "css" => "text/css; charset=utf-8",
10        "html" => "text/html; charset=utf-8",
11        "txt" => "text/plain; charset=utf-8",
12        "md" => "text/markdown; charset=utf-8",
13        "svg" => "image/svg+xml; charset=utf-8",
14        "wasm" => "application/wasm",
15        _ => return None,
16    })
17}