summaryrefslogtreecommitdiff
path: root/src/mime/mod.rs
blob: 4727f7eb817cf2fbdf89e76ebbdb19ef4119e66b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use std::ffi::OsStr;

pub fn default_mime_type() -> &'static str {
    "application/octet-stream"
}

pub fn get_mime_type(extension: &OsStr) -> &'static str {
    let ext_str = match extension.to_str() {
        Some(ext_str) => ext_str,
        None => {
            return default_mime_type();
        },
    };

    match ext_str {
        "gmi" => "text/gemini",
        "txt" => "text/plain",
        _ => default_mime_type(),
    }
}