Function wasm_framework::media_type [−][src]
pub fn media_type(file_path: &str) -> Option<&'static str>
Determines the Media Type (aka MIME) for file based on extension. If type is not known (based on implemented list), returns None.
assert_eq!(media_type("index.html"), Some("text/html; charset=utf-8"));
All type values are valid utf-8 strings, so it is safe to use unwrap() when setting headers, e.g.
if let Some(mtype) = media_type("index.html") { response.header(CONTENT_TYPE, mtype).unwrap(); } assert_eq!(55, 22);