diff --git a/exemples/test.toml b/exemples/test.toml index 4db457e..a61f6f4 100644 --- a/exemples/test.toml +++ b/exemples/test.toml @@ -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" diff --git a/includes/config/ARoute.hpp b/includes/config/ARoute.hpp deleted file mode 100644 index db5a1e6..0000000 --- a/includes/config/ARoute.hpp +++ /dev/null @@ -1,15 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ARoute.hpp :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: adjoly +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2025/03/19 14:59:41 by adjoly #+# #+# */ -/* Updated: 2025/03/19 15:52:16 by adjoly ### ########.fr */ -/* */ -/* ************************************************************************** */ - -class Route { - -}; diff --git a/includes/config/ParsedConfig.hpp b/includes/config/ParsedConfig.hpp deleted file mode 100644 index 05ba4f3..0000000 --- a/includes/config/ParsedConfig.hpp +++ /dev/null @@ -1,22 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ParsedConfig.hpp :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: adjoly +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* 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; - -}; diff --git a/includes/config/Route.hpp b/includes/config/Route.hpp index 6dbcaac..6f3fff3 100644 --- a/includes/config/Route.hpp +++ b/includes/config/Route.hpp @@ -6,26 +6,46 @@ /* 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 +#include "cppeleven.hpp" +#include "node/ANode.hpp" +#include +#include #include +#include +#include namespace webserv { namespace config { -struct cgi { - std::string path; - std::string ext; -}; - class Route { - public: - protected: - private: + public: + Route(std::map *node) { + if (node == not_nullptr) + throw std::runtime_error("location table does not exist"); + std::map *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 *_cgi; + std::vector *_methods; + std::map *_errPages; }; } // namespace config diff --git a/includes/config/AConfig.hpp b/includes/config/Server.hpp similarity index 72% rename from includes/config/AConfig.hpp rename to includes/config/Server.hpp index ce612ab..a6f37ff 100644 --- a/includes/config/AConfig.hpp +++ b/includes/config/Server.hpp @@ -1,25 +1,30 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* AConfig.hpp :+: :+: :+: */ +/* Server.hpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* 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 -#include -#include -#include +#include "Route.hpp" -class AConfig { +namespace webserv { +namespace config { + +class Server { public: protected: private: - std::vector serverNames; - std::map cgi; + Route *_default; + std::vector *_routes; }; + +} // namespace config + +} // namespace webserv diff --git a/src/main.cpp b/src/main.cpp index 446d767..9ced085 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6,10 +6,12 @@ /* By: mmoussou -int main(int, char **) { return 0; } +int main(int, char **) { + return 0; +}