45 lines
908 B
C++
45 lines
908 B
C++
// SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
#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>
|
|
|
|
#include <nlohmann/json.hpp>
|
|
|
|
#include "request/request.h"
|
|
#include "response/response.h"
|
|
#include "router.h"
|
|
#include "database/dbinterface.h"
|
|
|
|
class Server {
|
|
public:
|
|
Server();
|
|
~Server();
|
|
|
|
void run(int socketDescriptor);
|
|
|
|
private:
|
|
void handleRequest(std::unique_ptr<Request> request);
|
|
|
|
static bool info(Request* request, Server* server);
|
|
static bool printEnvironment(Request* request, Server* server);
|
|
|
|
private:
|
|
bool terminating;
|
|
uint64_t requestCount;
|
|
std::optional<std::string> serverName;
|
|
Router router;
|
|
std::unique_ptr<DBInterface> db;
|
|
};
|