🔨」 fix: fixed issue with tomlpp

This commit is contained in:
2025-04-23 17:42:32 +02:00
parent f94f060821
commit 91c3833c7c
2 changed files with 20 additions and 9 deletions

View File

@ -25,15 +25,15 @@ cgi.go = "/bin/go"
[server.location./redir] [server.location./redir]
redirect = "https://kanel.ovh" redirect = "https://kanel.ovh"
[server1] [server3]
server_names = { "ptnnnn.local"} server_names = { "ptnnnn.local"}
host = "0.0.0.0" host = "127.0.0.2"
port = 90 port = 9090
[server1.error_pages] [serverr.error_pages]
404 = "existepasfd***.html" 404 = "existepasfd***.html"
[server1.location./] [serverr.location./]
methods = { "GET", "DELETE" } methods = { "GET", "DELETE" }
root = "/var/lib/docker/volumes/test_data/_data" root = "/var/lib/docker/volumes/test_data/_data"
dirlist = false dirlist = false

View File

@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */ /* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/14 12:53:54 by adjoly #+# #+# */ /* Created: 2025/04/14 12:53:54 by adjoly #+# #+# */
/* Updated: 2025/04/22 15:35:52 by adjoly ### ########.fr */ /* Updated: 2025/04/23 17:42:07 by adjoly ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -15,13 +15,19 @@
#include "cppeleven.hpp" #include "cppeleven.hpp"
#include "node/ANode.hpp" #include "node/ANode.hpp"
#include <config/default.hpp> #include <config/default.hpp>
#include <stdexcept>
using namespace webserv::config; using namespace webserv::config;
Config::Config(std::string &filename) { Config::Config(std::string &filename) {
toml::Toml *file = new toml::Toml(filename); toml::Toml *file = new toml::Toml(filename);
try {
file->parse(); file->parse();
} catch (std::runtime_error &e) {
delete file;
throw e;
}
toml::ANode *table = file->getParsedFile(); toml::ANode *table = file->getParsedFile();
bool found = false; bool found = false;
@ -36,8 +42,13 @@ Config::Config(std::string &filename) {
for (auto it = prange(node)) { for (auto it = prange(node)) {
if (it->second->type() == toml::TABLE) { if (it->second->type() == toml::TABLE) {
_log->info("taking server from table : " + it->first); _log->info("taking server from table : " + it->first);
try {
Server *srv = new Server(it->second); Server *srv = new Server(it->second);
_servers.push_back(srv); _servers.push_back(srv);
} catch (std::runtime_error &e) {
_log->error(e.what());
break;
}
} }
} }
delete table; delete table;