mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2025-05-15 01:08:27 +00:00
parent
e46cc54d13
commit
6c5d0b2a18
8 changed files with 255 additions and 103 deletions
|
@ -81,25 +81,25 @@ int main(void)
|
|||
return -1;
|
||||
}
|
||||
|
||||
svr.get("/", [=](const auto& /*req*/, auto& res) {
|
||||
svr.Get("/", [=](const auto& /*req*/, auto& res) {
|
||||
res.set_redirect("/hi");
|
||||
});
|
||||
|
||||
svr.get("/hi", [](const auto& /*req*/, auto& res) {
|
||||
svr.Get("/hi", [](const auto& /*req*/, auto& res) {
|
||||
res.set_content("Hello World!\n", "text/plain");
|
||||
});
|
||||
|
||||
svr.get("/slow", [](const auto& /*req*/, auto& res) {
|
||||
svr.Get("/slow", [](const auto& /*req*/, auto& res) {
|
||||
using namespace std::chrono_literals;
|
||||
std::this_thread::sleep_for(2s);
|
||||
res.set_content("Slow...\n", "text/plain");
|
||||
});
|
||||
|
||||
svr.get("/dump", [](const auto& req, auto& res) {
|
||||
svr.Get("/dump", [](const auto& req, auto& res) {
|
||||
res.set_content(dump_headers(req.headers), "text/plain");
|
||||
});
|
||||
|
||||
svr.get("/stop", [&](const auto& /*req*/, auto& /*res*/) {
|
||||
svr.Get("/stop", [&](const auto& /*req*/, auto& /*res*/) {
|
||||
svr.stop();
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue