FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
expresscpp/src/request.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
/
request.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
129 lines (98 loc) · 2.67 KB
Breadcrumbs
expresscpp
/
src
/
request.cpp
Copy path
File metadata and controls
129 lines (98 loc) · 2.67 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#
include
"
expresscpp/request.hpp
"
#
include
<
chrono
>
#
include
<
iomanip
>
#
include
<
iostream
>
#
include
<
sstream
>
#
include
"
boost/uuid/uuid_generators.hpp
"
#
include
"
boost/uuid/uuid_io.hpp
"
using
namespace
std
::string_literals
;
namespace
expresscpp
{
Request::Request
(std::string_view path, HttpMethod method) : path_(path), method_(method) {
Init
();
}
void
Request::Init
() {
timestamp_ =
std::chrono::system_clock::now
();
uuid_ =
boost::uuids::random_generator
()();
originalUrl_ = path_;
}
std::string
Request::getBody
()
const
{
return
body_;
}
void
Request::setBody
(
const
std::string &body) {
body_ = body;
}
HttpMethod
Request::getMethod
()
const
{
return
method_;
}
void
Request::setMethod
(
const
HttpMethod &method) {
method_ = method;
}
std::shared_ptr<Route>
Request::getRoute
()
const
{
return
route_;
}
void
Request::setRoute
(
const
std::shared_ptr<Route> &route) {
route_ = route;
}
void
Request::setHeader
(
const
std::string &key,
const
std::string &value) {
headers_[key] = value;
}
std::string
Request::getHeader
(
const
std::string &key)
const
{
const
auto
itr = headers_.
find
(key);
if
(itr != headers_.
end
()) {
return
itr->
second
;
}
return
"
"
;
}
std::map<std::string, std::string>
Request::getHeaders
()
const
{
return
headers_;
}
std::string_view
Request::getPath
()
const
{
return
path_;
}
void
Request::setPath
(
const
std::string_view &path) {
path_ = path;
}
std::string
Request::getTimeStamp
()
const
{
time_t
now_time =
std::chrono::system_clock::to_time_t
(timestamp_);
const
auto
gmt_time =
gmtime
(&now_time);
std::stringstream ss;
ss <<
std::put_time
(gmt_time,
"
%Y-%m-%d %H:%M:%S
"
);
return
ss.
str
();
}
std::string
Request::getBaseUrl
()
const
{
return
baseUrl_;
}
void
Request::setBaseUrl
(
const
std::string &baseUrl) {
baseUrl_ = baseUrl;
}
std::string
Request::getOriginalUrl
()
const
{
return
originalUrl_;
}
void
Request::setOriginalUrl
(
const
std::string &originalUrl) {
originalUrl_ = originalUrl;
}
std::string
Request::getUrl
()
const
{
return
url_;
}
void
Request::setUrl
(
const
std::string &url) {
url_ = url;
}
const
std::map<std::string, std::string> &
Request::GetParams
()
const
{
return
params_;
}
void
Request::SetParams
(
const
std::map<std::string, std::string> ¶ms) {
params_ = params;
}
const
std::map<std::string, std::string> &
Request::GetQueryParams
()
const
{
return
query_params_;
}
void
Request::SetQueryString
(
const
std::string &query_string) {
query_string_ = query_string;
}
void
Request::SetQueryParams
(
const
std::map<std::string, std::string> &query_params) {
query_params_ = query_params;
}
const
std::string &
Request::GetQueryString
()
const
{
return
query_string_;
}
}
//
namespace expresscpp
Back
|
FazBrowse Home
|
New Git URL