diff --git a/includes/config/Config.hpp b/includes/config/Config.hpp index 51eb335..e570ce7 100644 --- a/includes/config/Config.hpp +++ b/includes/config/Config.hpp @@ -6,13 +6,13 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/04/14 12:20:06 by adjoly #+# #+# */ -/* Updated: 2025/04/22 11:52:33 by mmoussou ### ########.fr */ +/* Updated: 2025/04/22 15:25:39 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ #pragma once -#include +#include namespace webserv { namespace config { diff --git a/includes/config/Server.hpp b/includes/config/Server.hpp index fb3f72b..5dfb258 100644 --- a/includes/config/Server.hpp +++ b/includes/config/Server.hpp @@ -6,14 +6,14 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/19 14:11:28 by adjoly #+# #+# */ -/* Updated: 2025/04/22 14:25:17 by adjoly ### ########.fr */ +/* Updated: 2025/04/22 15:25:58 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ #pragma once #include -#include +#include #include #include #include diff --git a/includes/config/default.hpp b/includes/config/default.hpp index b976777..3e77b19 100644 --- a/includes/config/default.hpp +++ b/includes/config/default.hpp @@ -6,15 +6,15 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/19 14:15:51 by adjoly #+# #+# */ -/* Updated: 2025/04/22 12:40:20 by adjoly ### ########.fr */ +/* Updated: 2025/04/22 15:28:31 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ #pragma once +#include #include #include -#include #include #include #include @@ -35,13 +35,13 @@ namespace config { * @return The value got or not_nullptr */ static inline void *accessValue(const std::string &name, toml::nodeType type, - toml::ANode *table, Logger *log) { + toml::ANode *table, Logger *log) { void *val; bool found = false; if (table == not_nullptr) return not_nullptr; - val = dynamic_cast(table)->access(name, type, found); + val = dynamic_cast(table)->access(name, type, found); if (found == true && val != not_nullptr) { return val; } else { diff --git a/includes/requests/HttpIMessage.hpp b/includes/requests/HttpIMessage.hpp index a357f8d..eb63d3e 100644 --- a/includes/requests/HttpIMessage.hpp +++ b/includes/requests/HttpIMessage.hpp @@ -6,7 +6,7 @@ /* By: mmoussou +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/04/14 12:53:54 by adjoly #+# #+# */ -/* Updated: 2025/04/22 14:31:34 by adjoly ### ########.fr */ +/* Updated: 2025/04/22 15:32:19 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ +#include "node/default.hpp" #include "webserv.hpp" #include "cppeleven.hpp" #include "node/ANode.hpp" @@ -33,8 +34,10 @@ Config::Config(std::string &filename) { std::map *node = table->getTable(); for (auto it = prange(node)) { - Server *srv = new Server(it->second); - _servers.push_back(srv); + if (it->second->type() == toml::TABLE) { + Server *srv = new Server(it->second); + _servers.push_back(srv); + } } delete table; delete file; diff --git a/src/config/Server.cpp b/src/config/Server.cpp index 9290d80..85ba913 100644 --- a/src/config/Server.cpp +++ b/src/config/Server.cpp @@ -6,18 +6,22 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/24 15:10:07 by adjoly #+# #+# */ -/* Updated: 2025/04/22 14:26:00 by adjoly ### ########.fr */ +/* Updated: 2025/04/22 15:25:06 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ -#include +#include "cppeleven.hpp" #include +#include using namespace webserv::config; Server::Server(toml::ANode *node) : _table(node) { bool found; + if (_table == not_nullptr) + return; + // host parsing void *host = accessValue("host", toml::STRING, _table, _log); if (host != not_nullptr) { diff --git a/src/main.cpp b/src/main.cpp index 4476e72..bc65aab 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6,7 +6,7 @@ /* By: mmoussou