🏗️」 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
cookies = false
cgi_path = "/bin/php"
cgi_ext = ".php"
cgi.py = "/usr/bin/python3"
client_max_body_size = "10M"
@ -24,14 +23,17 @@ client_max_body_size = "10M"
methods = { "GET" }
root = "/var/www/html"
dirlist = true
client_max_body_size = "10M"
[server.location./.error_pages]
500 = "uwu.html"
[server.location./api]
methods = { "GET", "POST" }
uploads = true
root = "/var/www/api"
upload_path = "/etc/webserv/up"
cgi_path = "/bin/go"
cgi_ext = ".go"
cgi.go = "/bin/go"
[server.location./redir]
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> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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:
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

View File

@ -6,10 +6,12 @@
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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>
int main(int, char **) { return 0; }
int main(int, char **) {
return 0;
}