FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
expresscpp/example/url_params.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
/
example
/
url_params.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
36 lines (28 loc) · 980 Bytes
Breadcrumbs
expresscpp
/
example
/
url_params.cpp
Copy path
File metadata and controls
36 lines (28 loc) · 980 Bytes
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
#
include
"
expresscpp/console.hpp
"
#
include
"
expresscpp/expresscpp.hpp
"
using
namespace
expresscpp
;
int
main
() {
ExpressCpp app;
app.
Get
(
"
/things/:id/datapoint/:uuid
"
, [](
auto
req,
auto
res,
auto
/*
next
*/
) {
std::cout <<
"
params:
"
<< std::endl;
for
(
const
auto
& [name, value] : req->
GetParams
()) {
std::cout <<
"
name:
"
<< name <<
"
, value:
"
<< value << std::endl;
}
res->
Json
(
R"(
{ "status": "ok" }
)"
);
});
constexpr
uint16_t
port =
8081
;
const
auto
output =
fmt::format
(
R"(
you can try now: "curl http://localhost:{}/things/1234/datapoint/080fc7a2-9128-4491-bc9d-df05a34064cb"
)"
,
port);
app.
Listen
(port,
[=](
auto
ec) {
if
(ec) {
std::cerr <<
"
ERROR:
"
<< ec.
message
() << std::endl;
std::cerr <<
"
exiting...
"
<< std::endl;
exit
(
1
);
}
std::cout << output << std::endl;
})
.
Run
();
return
0
;
}
Back
|
FazBrowse Home
|
New Git URL