2023-12-10 23:23:15 +00:00
|
|
|
// SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2023-11-21 22:19:08 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <string>
|
|
|
|
#include <sstream>
|
|
|
|
#include <optional>
|
|
|
|
#include <string_view>
|
|
|
|
#include <vector>
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
#include <fcgiapp.h>
|
|
|
|
#include <fcgio.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2023-11-23 19:57:32 +00:00
|
|
|
#include <nlohmann/json.hpp>
|
|
|
|
|
2023-11-21 22:19:08 +00:00
|
|
|
#include "request/request.h"
|
|
|
|
#include "response/response.h"
|
2023-11-23 19:57:32 +00:00
|
|
|
#include "router.h"
|
2023-12-07 20:32:43 +00:00
|
|
|
#include "database/dbinterface.h"
|
2023-12-11 23:29:55 +00:00
|
|
|
#include "utils/helpers.h"
|
|
|
|
#include "config.h"
|
2023-11-21 22:19:08 +00:00
|
|
|
|
|
|
|
class Server {
|
|
|
|
public:
|
|
|
|
Server();
|
|
|
|
~Server();
|
|
|
|
|
|
|
|
void run(int socketDescriptor);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void handleRequest(std::unique_ptr<Request> request);
|
2023-11-23 19:57:32 +00:00
|
|
|
|
2023-11-21 22:19:08 +00:00
|
|
|
private:
|
|
|
|
bool terminating;
|
|
|
|
uint64_t requestCount;
|
|
|
|
std::optional<std::string> serverName;
|
2023-11-23 19:57:32 +00:00
|
|
|
Router router;
|
2023-12-07 20:32:43 +00:00
|
|
|
std::unique_ptr<DBInterface> db;
|
2023-11-21 22:19:08 +00:00
|
|
|
};
|