-
Notifications
You must be signed in to change notification settings - Fork 0
/
ServerConfig.hpp
49 lines (41 loc) · 1.88 KB
/
ServerConfig.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ServerConfig.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: yu <yu@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/19 10:44:59 by yu #+# #+# */
/* Updated: 2024/05/30 16:56:14 by yu ### ########.fr */
/* */
/* ************************************************************************** */
#pragma once
#include "LocationConfig.hpp"
#include <dirent.h>
#include <map>
#include <stdexcept>
#include <string>
#include <sys/types.h>
#include <vector>
class ServerConfig {
public:
ServerConfig();
// getters
std::vector< std::string > getServerNames() const;
std::string getListen() const;
std::map< int, std::string > getErrorPages() const;
std::map< std::string, LocationConfig > getLocations() const;
// setters
void addServerName(const std::vector< std::string > &tokens, size_t &pos);
void setListen(const std::vector< std::string > &tokens, size_t &pos);
void addErrorPage(const std::vector< std::string > &tokens, size_t &pos);
void addLocation(const std::string &path, const LocationConfig &location);
// methods
bool hasRootLocation() const;
private:
std::vector< std::string > _server_name;
std::string _listen;
std::map< std::string, LocationConfig > _locations;
std::map< int, std::string > _error_pages;
};
ServerConfig parseServer(const std::vector< std::string > &tokens, size_t &pos);