FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
expresscpp/src/utils.cpp at master · expresscpp/expresscpp · GitHub
expresscpp
/
expresscpp
Public
Notifications
You must be signed in to change notification settings
Fork
15
Star
96
Code
Issues
5
Pull requests
2
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
expresscpp
/
src
/
utils.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
102 lines (92 loc) · 2.12 KB
Breadcrumbs
expresscpp
/
src
/
utils.cpp
Copy path
File metadata and controls
102 lines (92 loc) · 2.12 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#
include
"
expresscpp/impl/utils.hpp
"
#
include
"
boost/lexical_cast.hpp
"
#
include
"
boost/uuid/uuid_io.hpp
"
#
include
"
expresscpp/console.hpp
"
namespace
expresscpp
{
std::string
boostUUIDToString
(
const
boost::uuids::uuid& uuid) {
return
boost::lexical_cast<std::string>(uuid);
}
std::string
getFileName
(
const
std::string& s) {
char
sep =
'
/
'
;
#
ifdef
_WIN32
sep =
'
\\
'
;
#
endif
size_t
i = s.
rfind
(sep, s.
length
());
if
(i != std::string::npos) {
return
(s.
substr
(i +
1
, s.
length
() - i));
}
return
(
"
"
);
}
boost::beast::string_view
mime_type
(boost::beast::string_view path) {
using
boost::beast::iequals;
auto
const
ext = [&path] {
auto
const
pos = path.
rfind
(
"
.
"
);
if
(pos == boost::beast::string_view::npos)
return
boost::beast::string_view{};
return
path.
substr
(pos);
}();
if
(
iequals
(ext,
"
.htm
"
)) {
return
"
text/html
"
;
}
if
(
iequals
(ext,
"
.html
"
)) {
return
"
text/html
"
;
}
if
(
iequals
(ext,
"
.php
"
)) {
return
"
text/html
"
;
}
if
(
iequals
(ext,
"
.css
"
)) {
return
"
text/css
"
;
}
if
(
iequals
(ext,
"
.txt
"
)) {
return
"
text/plain
"
;
}
if
(
iequals
(ext,
"
.js
"
)) {
return
"
application/javascript
"
;
}
if
(
iequals
(ext,
"
.xml
"
)) {
return
"
application/xml
"
;
}
if
(
iequals
(ext,
"
.swf
"
)) {
return
"
application/x-shockwave-flash
"
;
}
if
(
iequals
(ext,
"
.flv
"
)) {
return
"
video/x-flv
"
;
}
if
(
iequals
(ext,
"
.png
"
)) {
return
"
image/png
"
;
}
if
(
iequals
(ext,
"
.jpe
"
)) {
return
"
image/jpeg
"
;
}
if
(
iequals
(ext,
"
.jpeg
"
)) {
return
"
image/jpeg
"
;
}
if
(
iequals
(ext,
"
.jpg
"
)) {
return
"
image/jpeg
"
;
}
if
(
iequals
(ext,
"
.gif
"
)) {
return
"
image/gif
"
;
}
if
(
iequals
(ext,
"
.bmp
"
)) {
return
"
image/bmp
"
;
}
if
(
iequals
(ext,
"
.ico
"
)) {
return
"
image/vnd.microsoft.icon
"
;
}
if
(
iequals
(ext,
"
.tiff
"
)) {
return
"
image/tiff
"
;
}
if
(
iequals
(ext,
"
.tif
"
)) {
return
"
image/tiff
"
;
}
if
(
iequals
(ext,
"
.svg
"
)) {
return
"
image/svg+xml
"
;
}
if
(
iequals
(ext,
"
.svgz
"
)) {
return
"
image/svg+xml
"
;
}
if
(
iequals
(ext,
"
.json
"
)) {
return
"
application/json
"
;
}
return
"
application/text
"
;
}
}
//
namespace expresscpp
Back
|
FazBrowse Home
|
New Git URL