diff --git a/includes/config/Route.hpp b/includes/config/Route.hpp index f28560b..47a0b3d 100644 --- a/includes/config/Route.hpp +++ b/includes/config/Route.hpp @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/19 14:59:41 by adjoly #+# #+# */ -/* Updated: 2025/05/28 09:52:21 by adjoly ### ########.fr */ +/* Updated: 2025/06/09 18:35:35 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/src/config/Route.cpp b/src/config/Route.cpp index f7de719..686bfcb 100644 --- a/src/config/Route.cpp +++ b/src/config/Route.cpp @@ -26,8 +26,7 @@ std::vector *Route::_parseCGI(toml::ANode *table) { if ((*it)->type() == toml::STRING) { std::string str = *static_cast((*it)->getValue()); cgi->push_back(str); - } - else { + } else { std::stringstream str; str << "Was expecting a: " << toml::nodeTypeToStr(toml::STRING); str << ", but got a: " << toml::nodeTypeToStr((*it)->type()); @@ -61,10 +60,37 @@ Route::Route(toml::ANode *table) : _max_body(10485760) { void *val; bool found; + if (table == not_nullptr) { + _log->warn("is empty"); + _index = "index.html"; + _redirect = false; + _dirlist = false; + _up_root = ""; +#ifdef PKGS + _root = "/usr/share/webserv"; +#else + _root = "./html"; +#endif + _cgi = not_nullptr; + return; + } _table = table; if (_table->type() != toml::TABLE) { _log->warn("location need to be a table and not a :" + toml::nodeTypeToStr(_table->type())); + _index = "index.html"; + _redirect = false; + _dirlist = false; + _up_root = ""; +#ifdef PKGS + _root = "/usr/share/webserv"; +#else + _root = "./html"; +#endif + _cgi = not_nullptr; + _methods[0] = true; + _methods[1] = false; + _methods[2] = false; return; } val = accessValue("redirect", toml::STRING, _table, _log); @@ -79,11 +105,6 @@ Route::Route(toml::ANode *table) : _max_body(10485760) { _dirlist = *static_cast(val); else _dirlist = false; - /* val = accessValue("cookies", toml::BOOL, _table, _log); */ - /* if (val != not_nullptr) */ - /* _cookies = *static_cast(val); */ - /* else */ - /* _cookies = false; */ val = accessValue("upload_path", toml::STRING, _table, _log); if (val != not_nullptr) _up_root = *static_cast(val); diff --git a/src/config/Server.cpp b/src/config/Server.cpp index 26883ac..2b9c182 100644 --- a/src/config/Server.cpp +++ b/src/config/Server.cpp @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/24 15:10:07 by adjoly #+# #+# */ -/* Updated: 2025/05/28 11:42:25 by adjoly ### ########.fr */ +/* Updated: 2025/06/09 18:40:23 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -196,5 +196,7 @@ Server::Server(toml::ANode *node, void *) std::make_pair(URL(it->first), new Route(it->second))); } } + else + _routes = not_nullptr; // delete _table; }