FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
expresscpp/src/route.cpp at master · hpsware/expresscpp · GitHub
hpsware
/
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
/
route.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
63 lines (48 loc) · 1.44 KB
Breadcrumbs
expresscpp
/
src
/
route.cpp
Copy path
File metadata and controls
63 lines (48 loc) · 1.44 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
#
include
"
expresscpp/route.hpp
"
#
include
<
iostream
>
#
include
<
string_view
>
#
include
"
boost/lexical_cast.hpp
"
#
include
"
boost/uuid/uuid_generators.hpp
"
#
include
"
boost/uuid/uuid_io.hpp
"
#
include
"
expresscpp/console.hpp
"
#
include
"
expresscpp/http_method.hpp
"
#
include
"
expresscpp/impl/utils.hpp
"
#
include
"
expresscpp/layer.hpp
"
namespace
expresscpp
{
Route::Route
(std::string_view path) : path_(path) {
Init
();
}
Route::~Route
() {
Console::Debug
(
fmt::format
(
R"(
Destructing the route "{}"
)"
,
boostUUIDToString
(uuid_)));
}
void
Route::Init
() {
uuid_ =
boost::uuids::random_generator
()();
Console::Debug
(
fmt::format
(
R"(
Route created for path: "{}", uuid:"{}"
)"
, path_,
boostUUIDToString
(uuid_)));
}
std::string_view
Route::GetPath
()
const
{
return
path_;
}
void
Route::SetPath
(
const
std::string_view& path) {
path_ = path;
}
bool
Route::HasMethod
(HttpMethod method) {
if
(methods_.
find
(HttpMethod::All) != methods_.
end
()) {
return
true
;
}
if
(method == HttpMethod::Head && (methods_.
find
(HttpMethod::Head) == methods_.
end
())) {
method = HttpMethod::Get;
}
if
(methods_.
find
(method) != methods_.
end
()) {
return
true
;
}
return
false
;
}
void
Route::Dispatch
(
request_t
req,
response_t
res,
next_t
next) {
Console::Debug
(
fmt::format
(
"
Dispatch called {}
"
, boost::lexical_cast<std::string>(uuid_)));
for
(
const
auto
& l : stack_) {
if
(l !=
nullptr
) {
l->
HandleRequest
(req, res, next);
}
}
}
}
//
namespace expresscpp
Back
|
FazBrowse Home
|
New Git URL