mirror of
https://github.com/3lswear/webserv.git
synced 2025-10-28 21:07:59 +03:00
ServerConfig class
This commit is contained in:
59
includes/ServerConfig.hpp
Normal file
59
includes/ServerConfig.hpp
Normal file
@@ -0,0 +1,59 @@
|
||||
#ifndef SERVERCONFIG_HPP
|
||||
#define SERVERCONFIG_HPP
|
||||
|
||||
#include "webserv.hpp"
|
||||
|
||||
struct location
|
||||
{
|
||||
std::string location;
|
||||
std::string root;
|
||||
std::string directoryFile;
|
||||
std::string uploadDir;
|
||||
bool autoindex;
|
||||
bool uploadAccept;
|
||||
std::vector<std::string> methods;
|
||||
std::map<int, std::string> redirect;
|
||||
};
|
||||
|
||||
class ServerConfig
|
||||
{
|
||||
private:
|
||||
// TOMLMap *_root;
|
||||
std::string _serverName;
|
||||
std::string _host;
|
||||
int _port;
|
||||
int _clientBodySize;
|
||||
|
||||
std::map<int, std::string> _errorPages;
|
||||
std::vector<location> _locations;
|
||||
|
||||
public:
|
||||
void setServerName(std::string);
|
||||
void setHost(std::string);
|
||||
void setPort(int);
|
||||
void setClientBodySize(int);
|
||||
void setErrorPages(std::map<int, std::string>);
|
||||
void setLocations(std::vector<location>);
|
||||
// void setRoot(TOMLMap *);
|
||||
|
||||
std::string getServerName(void);
|
||||
std::string getHost(void);
|
||||
int getPort(void);
|
||||
int getClientBodySize(void);
|
||||
std::vector<location> getLocations(void);
|
||||
std::map<int, std::string> getErrorPages(void);
|
||||
// TOMLMap *getRoot(void);
|
||||
|
||||
public:
|
||||
ServerConfig();
|
||||
// ServerConfig(TOMLMap *root);
|
||||
|
||||
void fillFields(void);
|
||||
|
||||
~ServerConfig();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef SOCKET
|
||||
#define SOCKET
|
||||
#ifndef SOCKET_HPP
|
||||
#define SOCKET_HPP
|
||||
|
||||
#include "webserv.hpp"
|
||||
class Socket
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
|
||||
#include "Socket.hpp"
|
||||
#include "HeaderHandl.hpp"
|
||||
#include "ServerConfig.hpp"
|
||||
#include "Autoindex.hpp"
|
||||
#include "Server.hpp"
|
||||
#include "Header.hpp"
|
||||
|
||||
100
src/ServerConfig.cpp
Normal file
100
src/ServerConfig.cpp
Normal file
@@ -0,0 +1,100 @@
|
||||
#include "ServerConfig.hpp"
|
||||
|
||||
ServerConfig::ServerConfig()
|
||||
{
|
||||
}
|
||||
|
||||
// ServerConfig::ServerConfig(TOMLMap *map)
|
||||
// {
|
||||
// _root = map;
|
||||
// }
|
||||
|
||||
//--------------------------------------------------GET/SET---------------------------------------
|
||||
std::string ServerConfig::getServerName(void)
|
||||
{
|
||||
return (_serverName);
|
||||
}
|
||||
|
||||
std::string ServerConfig::getHost(void)
|
||||
{
|
||||
return (_host);
|
||||
}
|
||||
|
||||
int ServerConfig::getPort(void)
|
||||
{
|
||||
return (_port);
|
||||
}
|
||||
|
||||
int ServerConfig::getClientBodySize(void)
|
||||
{
|
||||
return (_clientBodySize);
|
||||
}
|
||||
|
||||
std::vector<location> ServerConfig::getLocations(void)
|
||||
{
|
||||
return (_locations);
|
||||
}
|
||||
|
||||
std::map<int, std::string> ServerConfig::getErrorPages(void)
|
||||
{
|
||||
return (_errorPages);
|
||||
}
|
||||
|
||||
// TOMLMap ServerConfig::*getRoot(void)
|
||||
// {
|
||||
// return (this->_root);
|
||||
// }
|
||||
|
||||
void ServerConfig::setServerName(std::string name)
|
||||
{
|
||||
_serverName = name;
|
||||
}
|
||||
|
||||
void ServerConfig::setHost(std::string host)
|
||||
{
|
||||
_host = host;
|
||||
}
|
||||
|
||||
void ServerConfig::setPort(int port)
|
||||
{
|
||||
_port = port;
|
||||
}
|
||||
|
||||
void ServerConfig::setClientBodySize(int body)
|
||||
{
|
||||
_clientBodySize = body;
|
||||
}
|
||||
|
||||
void ServerConfig::setErrorPages(std::map<int, std::string> pages)
|
||||
{
|
||||
_errorPages = pages;
|
||||
}
|
||||
|
||||
void ServerConfig::setLocations(std::vector<location> locations)
|
||||
{
|
||||
_locations = locations;
|
||||
}
|
||||
|
||||
// void ServerConfig::setRoot(TOMLMap * data)
|
||||
// {
|
||||
// _root = data;
|
||||
// }
|
||||
|
||||
|
||||
void ServerConfig::fillFields(void)
|
||||
{
|
||||
// TOMLMap *tmp = _root;
|
||||
// TOMLMap::iterator it;
|
||||
|
||||
// it = tmp->begin();
|
||||
|
||||
// while (it != tmp->end())
|
||||
// {
|
||||
// std::cout << it->first << std::endl;
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
ServerConfig::~ServerConfig()
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user