109 lines
3.2 KiB
C++
109 lines
3.2 KiB
C++
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ServerConfig.hpp :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: me <erlazo@student.42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2022/07/23 15:55:16 by me #+# #+# */
|
|
/* Updated: 2022/07/23 16:19:43 by me ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#ifndef SERVERCONFIG_HPP
|
|
# define SERVERCONFIG_HPP
|
|
|
|
# include "MethodType.hpp"
|
|
# include "LocationConfig.hpp"
|
|
|
|
# include <map>
|
|
# include <vector>
|
|
# include <string> // string
|
|
# include <iostream> // cout, cin
|
|
|
|
// a class that's all public? just so we have options?
|
|
class ServerConfig
|
|
{
|
|
public:
|
|
|
|
// i mean i guess i need some canonic stuff?
|
|
// although maybe if i make it a struct i can barebones it?
|
|
|
|
|
|
std::string server_name;
|
|
std::string root;
|
|
|
|
std::vector<std::string> index;
|
|
std::map<int, std::string> error_pages;
|
|
|
|
// i'm tempted to do something diff for storing method types...
|
|
std::vector<MethodType> allow_methods;
|
|
|
|
std::vector<LocationConfig> locations;
|
|
|
|
// might do something diff
|
|
struct timeval send_timeout;
|
|
struct timeval recv_timeout;
|
|
|
|
int client_body_limit; // set to default max if none set
|
|
bool autoindex;
|
|
|
|
// not sure what these look like in config file
|
|
int redirect_status;
|
|
std::string redirect_uri;
|
|
|
|
// is this the best way?
|
|
std::string host;
|
|
std::string port; // port needs to be something else... not quite an int
|
|
// should a Server be able to handle several?
|
|
|
|
|
|
|
|
// do i need a print all for testing?
|
|
|
|
|
|
void print_all()
|
|
{
|
|
std::cout << "PRINTING A FULL SERVER CONFIG\n\n";
|
|
|
|
std::cout << "Server_name: " << server_name << '\n';
|
|
std::cout << "root: " << root << '\n';
|
|
std::cout << "index: ";
|
|
for (size_t i = 0; i < index.size(); i++)
|
|
std::cout << index[i] << " ";
|
|
std::cout << "\nerror_pages: ";
|
|
for(std::map<int, std::string>::iterator it = error_pages.begin(); \
|
|
it != error_pages.end(); it++)
|
|
std::cout << it->first << "--" << it->second << " ";
|
|
// for (size_t i = 0; i < error_pages.size(); i++)
|
|
// std::cout << error_pages->first << "--" << error_pages->second << " ";
|
|
std::cout << "\nallow_methods: ";
|
|
for (size_t i = 0; i < allow_methods.size(); i++)
|
|
std::cout << allow_methods[i] << " ";
|
|
std::cout << "\nskiping Locations for now...\n";
|
|
std::cout << "also skiping send_timeout and recv\n";
|
|
std::cout << "autoindex: " << autoindex << '\n';
|
|
std::cout << "client_body_limit: " << client_body_limit << '\n';
|
|
std::cout << "redirect_status: " << redirect_status << '\n';
|
|
std::cout << "redirect_uri: " << redirect_uri << '\n';
|
|
std::cout << "host: " << host << '\n';
|
|
std::cout << "port: " << port << '\n';
|
|
|
|
std::cout << "\n----------\n";
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|