1
0
forked from blue/pica
pica/server/server.h

47 lines
976 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 <argon2.h>
#include "request/request.h"
#include "response/response.h"
#include "router.h"
#include "database/dbinterface.h"
#include "utils/helpers.h"
#include "config.h"
class Server {
public:
Server();
~Server();
void run(int socketDescriptor);
unsigned int registerAccount(const std::string& login, const std::string& password);
private:
void handleRequest(std::unique_ptr<Request> request);
static std::string generateRandomString(std::size_t length);
private:
bool terminating;
uint64_t requestCount;
std::optional<std::string> serverName;
Router router;
std::unique_ptr<DBInterface> db;
};