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-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
|
|
|
|
|
|
|
static bool info(Request* request);
|
|
|
|
static bool printEnvironment(Request* request);
|
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-11-21 22:19:08 +00:00
|
|
|
};
|