mirror of
https://github.com/KeyZox71/webserv.git
synced 2025-05-10 19:38:45 +02:00
「✨」 feat: added getserver in config to get a server from a server_name
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/04/14 12:20:06 by adjoly #+# #+# */
|
||||
/* Updated: 2025/04/18 10:03:09 by adjoly ### ########.fr */
|
||||
/* Updated: 2025/04/22 10:57:26 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -24,10 +24,11 @@ class Config {
|
||||
|
||||
Logger *getLogger(void) { return _log; }
|
||||
|
||||
std::vector<Server *> *getServers(void) { return _servers; }
|
||||
std::vector<Server *> getServers(void) { return _servers; }
|
||||
Server *getServer(const std::string &);
|
||||
|
||||
private:
|
||||
std::vector<Server *> *_servers;
|
||||
std::vector<Server *> _servers;
|
||||
};
|
||||
|
||||
}; // namespace config
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/03/19 14:11:28 by adjoly #+# #+# */
|
||||
/* Updated: 2025/04/18 10:08:33 by adjoly ### ########.fr */
|
||||
/* Updated: 2025/04/22 10:59:27 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
#include "config/default.hpp"
|
||||
#include "cppeleven.hpp"
|
||||
#include "node/ANode.hpp"
|
||||
#include "webserv.hpp"
|
||||
|
||||
namespace webserv {
|
||||
namespace config {
|
||||
@ -55,6 +56,16 @@ class Server {
|
||||
// @brief Can be used to get the port specified in the config file
|
||||
int getPort(void) { return _port; }
|
||||
|
||||
// @brief Can be used to check if a servername is present in this config
|
||||
bool isServerName(const std::string &server_name) {
|
||||
for (auto it = prange(_server_names)) {
|
||||
if (*it == server_name) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected:
|
||||
private:
|
||||
std::map<std::string, Route *>
|
||||
|
Reference in New Issue
Block a user