FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
expresscpp/src/http_method.cpp at master · Dmdv/expresscpp · GitHub
Dmdv
/
expresscpp
Public
forked from
expresscpp/expresscpp
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
expresscpp
/
src
/
http_method.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
91 lines (83 loc) · 2.59 KB
Breadcrumbs
expresscpp
/
src
/
http_method.cpp
Copy path
File metadata and controls
91 lines (83 loc) · 2.59 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
#
include
"
expresscpp/http_method.hpp
"
#
include
<
cctype
>
#
include
<
string
>
#
include
<
string_view
>
#
include
<
ostream
>
namespace
expresscpp
{
HttpMethod
beastVerbToHttpMethod
(
const
boost::beast::http::verb beast_verb) {
switch
(beast_verb) {
case
boost::beast::http::verb::get:
return
HttpMethod::Get;
case
boost::beast::http::verb::
post
:
return
HttpMethod::Post;
case
boost::beast::http::verb::delete_:
return
HttpMethod::Delete;
case
boost::beast::http::verb::patch:
return
HttpMethod::Patch;
case
boost::beast::http::verb::put:
return
HttpMethod::Put;
default
:
return
HttpMethod::All;
}
}
std::string
getHttpMethodName
(
const
HttpMethod method) {
switch
(method) {
case
HttpMethod::All:
return
"
ALL
"
;
case
HttpMethod::Get:
return
"
GET
"
;
case
HttpMethod::Post:
return
"
POST
"
;
case
HttpMethod::Put:
return
"
PUT
"
;
case
HttpMethod::Delete:
return
"
DELETE
"
;
case
HttpMethod::Patch:
return
"
PATCH
"
;
case
HttpMethod::Head:
return
"
HEAD
"
;
default
:
throw
std::runtime_error
(
"
method not found
"
+
std::to_string
(
static_cast
<
int
>(method)));
}
}
boost::beast::http::verb
getBeastVerbFromExpressVerb
(
const
HttpMethod method) {
switch
(method) {
case
HttpMethod::All:
return
boost::beast::http::verb::unknown;
case
HttpMethod::Get:
return
boost::beast::http::verb::get;
case
HttpMethod::Post:
return
boost::beast::http::verb::
post
;
case
HttpMethod::Put:
return
boost::beast::http::verb::put;
case
HttpMethod::Delete:
return
boost::beast::http::verb::delete_;
case
HttpMethod::Patch:
return
boost::beast::http::verb::patch;
case
HttpMethod::Head:
return
boost::beast::http::verb::head;
default
:
throw
std::runtime_error
(
"
method not found
"
+
std::to_string
(
static_cast
<
int
>(method)));
}
}
HttpMethod
getHttpMethodFromName
(
const
std::string_view method) {
std::string method_s = method.
data
();
std::transform
(method_s.
begin
(), method_s.
end
(), method_s.
begin
(), ::toupper);
if
(method_s ==
"
ALL
"
) {
return
HttpMethod::All;
}
else
if
(method_s ==
"
GET
"
) {
return
HttpMethod::Get;
}
else
if
(method_s ==
"
POST
"
) {
return
HttpMethod::Post;
}
else
if
(method_s ==
"
PATCH
"
) {
return
HttpMethod::Patch;
}
else
if
(method_s ==
"
PUT
"
) {
return
HttpMethod::Put;
}
else
if
(method_s ==
"
DELETE
"
) {
return
HttpMethod::Delete;
}
else
if
(method_s ==
"
HEAD
"
) {
return
HttpMethod::Head;
}
throw
std::runtime_error
(
std::string
(
"
method not found
"
) + method.
data
());
}
}
//
namespace expresscpp
Back
|
FazBrowse Home
|
New Git URL