summaryrefslogtreecommitdiff
path: root/src/mime/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/mime/mod.rs')
-rw-r--r--src/mime/mod.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/mime/mod.rs b/src/mime/mod.rs
new file mode 100644
index 0000000..4727f7e
--- /dev/null
+++ b/src/mime/mod.rs
@@ -0,0 +1,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(),
+ }
+}