🏗️」 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

@ -10,8 +10,7 @@ dirlist = false
uploads = false uploads = false
cookies = false cookies = false
cgi_path = "/bin/php" cgi.py = "/usr/bin/python3"
cgi_ext = ".php"
client_max_body_size = "10M" client_max_body_size = "10M"
@ -24,14 +23,17 @@ client_max_body_size = "10M"
methods = { "GET" } methods = { "GET" }
root = "/var/www/html" root = "/var/www/html"
dirlist = true dirlist = true
client_max_body_size = "10M"
[server.location./.error_pages]
500 = "uwu.html"
[server.location./api] [server.location./api]
methods = { "GET", "POST" } methods = { "GET", "POST" }
uploads = true uploads = true
root = "/var/www/api" root = "/var/www/api"
upload_path = "/etc/webserv/up" upload_path = "/etc/webserv/up"
cgi_path = "/bin/go" cgi.go = "/bin/go"
cgi_ext = ".go"
[server.location./redir] [server.location./redir]
redirect = "https://kanel.ovh" redirect = "https://kanel.ovh"

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> +#+ +:+ +#+ */ /* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/19 14:59:41 by adjoly #+# #+# */ /* 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 #pragma once
#include "cppeleven.hpp"
#include "node/ANode.hpp"
#include <map>
#include <stdexcept>
#include <string> #include <string>
#include <tomlpp.hpp>
#include <vector>
namespace webserv { namespace webserv {
namespace config { namespace config {
struct cgi {
std::string path;
std::string ext;
};
class Route { class Route {
public: public:
protected: Route(std::map<std::string, toml::ANode *> *node) {
private: 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 } // namespace config

View File

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

View File

@ -6,10 +6,12 @@
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */ /* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/03 15:45:07 by mmoussou #+# #+# */ /* Created: 2025/02/03 15:45:07 by mmoussou #+# #+# */
/* Updated: 2025/03/19 15:52:16 by adjoly ### ########.fr */ /* Updated: 2025/03/19 16:02:30 by adjoly ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include <tomlpp.hpp> #include <tomlpp.hpp>
int main(int, char **) { return 0; } int main(int, char **) {
return 0;
}