summaryrefslogtreecommitdiff
path: root/src/mime/mod.rs
diff options
context:
space:
mode:
authorJan Wolff <janw@mailbox.org>2020-05-17 12:54:10 +0200
committerJan Wolff <janw@mailbox.org>2020-05-17 12:54:10 +0200
commit872197c55805161e1ed6bbbd13b169b3bc809fd5 (patch)
tree600914246f6de5e7ae2cee82f0009aec3b2c77ac /src/mime/mod.rs
parent4a9c6c11acf4128b2c5158307088b0cbc377c3e5 (diff)
mime type handling and setuid/setgid support
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(),
+ }
+}