Webserv
Loading...
Searching...
No Matches
ServerConfig.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "ServerBlock.hpp"
4#include <ostream>
5
6namespace http {
7class Request;
8}
9
10namespace config {
11
12typedef std::map<int, ServerBlockVec> ServerBlockMap;
13
23public:
24 // ========================= Construction & Destruction =========================
25
27
33 explicit ServerConfig(char const *fpath, bool perform_fs_checks = true);
34
40 explicit ServerConfig(std::string const &content, bool perform_fs_checks = true);
41
42 // ============================== Public Interface ==============================
43
50 ServerBlock const *getServer(int port, http::Request const &req) const;
51
56 void addServer(ServerBlock const &server);
57
58 // ============================== Getters & Setters =============================
59
64 ServerBlockMap const &getServersMap() const;
65
66private:
73 void build(std::string const &content, bool perform_fs_checks);
74
76};
77
78std::ostream &operator<<(std::ostream &o, ServerConfig const &t);
79
80} // namespace config
Represents a single 'server' block from the configuration file.
Definition ServerBlock.hpp:22
A strongly-typed data container for a server block's configuration.
Definition ServerConfig.hpp:22
void addServer(ServerBlock const &server)
Adds a ServerBlock to the configuration.
Definition ServerConfig.cpp:68
ServerBlock const * getServer(int port, http::Request const &req) const
Retrieves the server configuration that best matches a port and server name.
Definition ServerConfig.cpp:44
void build(std::string const &content, bool perform_fs_checks)
Definition ServerConfig.cpp:31
ServerBlockMap const & getServersMap() const
Gets read-only access to the map of server blocks.
Definition ServerConfig.cpp:42
ServerBlockMap servers_
Map of server blocks, keyed by port number.
Definition ServerConfig.hpp:75
ServerConfig()
Definition ServerConfig.cpp:16
Definition Request.hpp:66
Definition ArgumentFactory.hpp:5
std::ostream & operator<<(std::ostream &o, Token const &t)
Definition Token.cpp:29
std::map< int, ServerBlockVec > ServerBlockMap
Definition ServerConfig.hpp:12
Definition IArgument.hpp:5