forked from scylladb/seastar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmime_types.cc
45 lines (39 loc) · 1.12 KB
/
mime_types.cc
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//
// mime_types.cpp
// ~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#include "mime_types.hh"
namespace httpd {
namespace mime_types {
struct mapping {
const char* extension;
const char* mime_type;
} mappings[] = {
{ "gif", "image/gif" },
{ "htm", "text/html" },
{ "css", "text/css" },
{ "js", "text/javascript" },
{ "html", "text/html" },
{ "jpg", "image/jpeg" },
{ "png", "image/png" },
{ "txt", "text/plain" },
{ "ico", "image/x-icon" },
{ "bin", "application/octet-stream" },
{ "proto", "application/vnd.google.protobuf; proto=io.prometheus.client.MetricFamily; encoding=delimited"},
};
const char* extension_to_type(const sstring& extension)
{
for (mapping m : mappings) {
if (extension == m.extension) {
return m.mime_type;
}
}
return "text/plain";
}
} // namespace mime_types
} // httpd