blob: dd8e3a712188ca31ec19297f50fd391baf9b7628 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#include "common.hh"
#include "mime_types.hh"
#include "strutil.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(str::to_lower_ascii(ext));
if (it == kExtensionMap.end())
return std::string_view();
return it->second;
}
} // namespace mime_types
|