summaryrefslogtreecommitdiff
path: root/src/mime_types.cc
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2021-11-17 22:34:57 +0100
committerJoel Klinghed <the_jk@spawned.biz>2021-11-17 22:34:57 +0100
commit6232d13f5321b87ddf12a1aa36b4545da45f173d (patch)
tree23f3316470a14136debd9d02f9e920ca2b06f4cc /src/mime_types.cc
Travel3: Simple image and video display site
Reads the images and videos from filesystem and builds a site in memroy.
Diffstat (limited to 'src/mime_types.cc')
-rw-r--r--src/mime_types.cc29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/mime_types.cc b/src/mime_types.cc
new file mode 100644
index 0000000..1332f5a
--- /dev/null
+++ b/src/mime_types.cc
@@ -0,0 +1,29 @@
+#include "common.hh"
+
+#include "mime_types.hh"
+
+#include <unordered_map>
+
+namespace mime_types {
+
+namespace {
+
+std::unordered_map<std::string_view, std::string_view> kExtensionMap({
+ { "css", "text/css" },
+ { "jpeg", "image/jpeg" },
+ { "jpg", "image/jpeg" },
+ { "js", "text/javascript" },
+ { "png", "image/png" },
+ { "webp", "image/webp" },
+});
+
+} // namespace
+
+std::string_view from_extension(std::string_view ext) {
+ auto it = kExtensionMap.find(ext);
+ if (it == kExtensionMap.end())
+ return std::string_view();
+ return it->second;
+}
+
+} // namespace mime_types