1
0
forked from cat/WebBase

Fix for adding boilerplate

This commit is contained in:
2025-06-18 01:47:58 +03:00
parent a256404a3d
commit a607e4c99f
5 changed files with 129 additions and 0 deletions

22
src/Webserver.cpp Normal file
View File

@@ -0,0 +1,22 @@
#include "main.hpp"
// Webserver is defined at main.hpp, you probably do not want to code here
Webserver::Webserver(asio::io_context &context)
: io(context),
accept(context,
asio::ip::tcp::endpoint(asio::ip::make_address(IP), PORT)) {
begin();
}
void Webserver::begin() {
HTTPrequest::HTTPrequest_ptr newconn = HTTPrequest::create(io);
accept.async_accept(newconn->socket(),
[this, newconn](const asio::error_code &err) {
if (!err) {
newconn->start();
}
begin();
});
}