forked from cat/WebBase
25 lines
698 B
C++
25 lines
698 B
C++
#include "Main.hpp"
|
|
#include <iostream>
|
|
|
|
// 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)) {
|
|
std::cout << "Server is up!\n";
|
|
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();
|
|
});
|
|
}
|