🏗️」 wip: implemented url class in config need to fix compilation

This commit is contained in:
2025-04-22 12:44:50 +02:00
parent 7ee79b6fa4
commit 43a34e759f
5 changed files with 20 additions and 21 deletions

View File

@ -6,16 +6,18 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/19 14:11:28 by adjoly #+# #+# */
/* Updated: 2025/04/22 12:34:14 by adjoly ### ########.fr */
/* Updated: 2025/04/22 12:44:16 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#pragma once
#include <webserv.hpp>
#include <config/default.hpp>
#include <cppeleven.hpp>
#include <node/ANode.hpp>
#include <webserv.hpp>
#include <config/URL.hpp>
namespace webserv {
namespace config {
@ -66,15 +68,18 @@ class Server {
return false;
}
Route *whatRoute(const std::string &route_path) {
Route *whatRoute(const URL &url) {
for (auto it = prange(_routes)) {
if (it->first == url) {
return it->second;
}
}
return not_nullptr;
}
protected:
private:
std::map<std::string, Route *>
std::map<URL, Route *>
*_routes; ///> A map of all the route present in the config file
std::map<int, std::string> *_err_pages; ///> An error pages map to map error
/// specified in the config file

View File

@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/22 12:17:48 by adjoly #+# #+# */
/* Updated: 2025/04/22 12:26:21 by adjoly ### ########.fr */
/* Updated: 2025/04/22 12:42:21 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
@ -26,6 +26,8 @@ class URL {
return comparePathSegments(other);
}
bool operator<(const URL &other) const { return _full_url < other._full_url; }
std::vector<std::string> getSegments(void) { return _path_segments; }
std::string getFullUrl(void) { return _full_url; }

View File

@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/19 14:15:51 by adjoly #+# #+# */
/* Updated: 2025/04/22 12:03:30 by mmoussou ### ########.fr */
/* Updated: 2025/04/22 12:40:20 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */

View File

@ -6,19 +6,13 @@
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/11 13:29:21 by mmoussou #+# #+# */
<<<<<<< HEAD
/* Updated: 2025/04/22 11:54:13 by mmoussou ### ########.fr */
=======
/* Updated: 2025/04/22 12:32:23 by adjoly ### ########.fr */
>>>>>>> 8129f45 (🏗 wip: added url class for easier manipulation)
/* Updated: 2025/04/22 12:43:26 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#pragma once
#include <sys/types.h>
#ifndef __WEBSERV_WEBSERV_HPP__
#define __WEBSERV_WEBSERV_HPP__
#include <sys/types.h>
#include <csignal>
#include <cstdlib>
#include <cstring>
@ -47,4 +41,3 @@ namespace webserv {
} // namespace webserv
#endif // __WEBSERV_WEBSERV_HPP__