🏗️」 wip: Started route class

This commit is contained in:
2025-03-19 17:39:03 +01:00
parent 43df2b18a7
commit 30951f436c
6 changed files with 52 additions and 60 deletions

View File

@ -1,15 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ARoute.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/19 14:59:41 by adjoly #+# #+# */
/* Updated: 2025/03/19 15:52:16 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
class Route {
};

View File

@ -1,22 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ParsedConfig.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/19 14:11:28 by adjoly #+# #+# */
/* Updated: 2025/03/19 15:52:16 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#pragma once
class config {
public:
protected:
private:
std::map cgi;
};

View File

@ -6,26 +6,46 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/19 14:59:41 by adjoly #+# #+# */
/* Updated: 2025/03/19 15:52:16 by adjoly ### ########.fr */
/* Updated: 2025/03/19 17:35:09 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#pragma once
#include "cppeleven.hpp"
#include "node/ANode.hpp"
#include <map>
#include <stdexcept>
#include <string>
#include <tomlpp.hpp>
#include <vector>
namespace webserv {
namespace config {
struct cgi {
std::string path;
std::string ext;
};
class Route {
public:
protected:
private:
public:
Route(std::map<std::string, toml::ANode *> *node) {
if (node == not_nullptr)
throw std::runtime_error("location table does not exist");
std::map<std::string, toml::ANode *> *errorPagesTable = (*node)["error_pages"]->getTable();
if (errorPagesTable == not_nullptr)
throw std::runtime_error("error_pages not present");
}
~Route(void) {}
protected:
private:
bool _dirlist;
bool _cookies;
bool _uploads;
bool _redirect;
int32_t _maxBody;
std::string _root;
std::string _upRoot;
std::map<std::string, std::string> *_cgi;
std::vector<std::string> *_methods;
std::map<int, std::string> *_errPages;
};
} // namespace config

View File

@ -1,25 +1,30 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* AConfig.hpp :+: :+: :+: */
/* Server.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/19 14:11:28 by adjoly #+# #+# */
/* Updated: 2025/03/19 14:27:56 by adjoly ### ########.fr */
/* Updated: 2025/03/19 16:54:35 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#pragma once
#include <map>
#include <string>
#include <vector>
#include "Route.hpp"
class AConfig {
namespace webserv {
namespace config {
class Server {
public:
protected:
private:
std::vector<std::string> serverNames;
std::map<std::string, std::string> cgi;
Route *_default;
std::vector<Route *> *_routes;
};
} // namespace config
} // namespace webserv