Added processFormData and reorganised the files
This commit is contained in:
16
src/Base/Entry.cpp
Normal file
16
src/Base/Entry.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include "../Main.hpp"
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
|
||||
// Entry point a.k.a "main.cpp"
|
||||
// You do not want to program here 99% of the time
|
||||
int main(int argc, char *argv[]) {
|
||||
try {
|
||||
asio::io_context context;
|
||||
Webserver server(context);
|
||||
context.run();
|
||||
} catch (std::exception &e) {
|
||||
std::cerr << e.what() << "\n";
|
||||
}
|
||||
return 0;
|
||||
}
|
27
src/Base/Webserver.cpp
Normal file
27
src/Base/Webserver.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#include "../Main.hpp"
|
||||
#include <iostream>
|
||||
#include <ostream>
|
||||
|
||||
// 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";
|
||||
initResponses();
|
||||
std::cout << "Path responses are set up!" << std::endl;
|
||||
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();
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user