SNode.C
Loading...
Searching...
No Matches
httpserver.cpp File Reference
Include dependency graph for httpserver.cpp:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 64 of file httpserver.cpp.

64 {
65 using WebApp = apps::http::STREAM::WebApp;
66
67 const WebApp webApp(apps::http::STREAM::getWebApp("httpserver"));
68
69 webApp.getConfig().Instance::newSubCommand<subcommand::ConfigWWW>();
70
71 WebApp::init(argc, argv);
72
73 webApp.use(express::middleware::StaticMiddleware(webApp.getConfig().Instance::getSubCommand<subcommand::ConfigWWW>()->getHtmlRoot()));
74
75 {
76#if (STREAM_TYPE == TLS)
77 std::string cert = "/home/voc/projects/snodec/snode.c/certs/snode.c_-_server.pem";
78 std::string key = "/home/voc/projects/snodec/snode.c/certs/Volker_Christian_-_Web_-_snode.c_-_server.key.encrypted.pem";
79 std::string pass = "snode.c";
80
81 std::map<std::string, std::map<std::string, std::variant<std::string, bool, ssl_option_t>>> const sniCerts = {
82 {"snodec.home.vchrist.at", {{"Cert", cert}, {"CertKey", key}, {"CertKeyPassword", pass}}},
83 {"www.vchrist.at", {{"Cert", cert}, {"CertKey", key}, {"CertKeyPassword", pass}}}};
84
85// webApp.getConfig().addSniCerts(sniCerts);
86#endif
87
88 VLOG(1) << "Routes:";
89 for (std::string& route : webApp.getRoutes()) {
90 route.erase(std::remove(route.begin(), route.end(), '$'), route.end());
91
92 VLOG(1) << " " << route;
93 }
94
95 webApp.listen([instanceName = webApp.getConfig().getInstanceName()](const core::socket::SocketAddress& socketAddress,
96 const core::socket::State& state) {
97 switch (state) {
98 case core::socket::State::OK:
99 VLOG(1) << instanceName << ": listening on '" << socketAddress.toString() << "'";
100 break;
101 case core::socket::State::DISABLED:
102 VLOG(1) << instanceName << ": disabled";
103 break;
104 case core::socket::State::ERROR:
105 VLOG(1) << instanceName << ": " << socketAddress.toString() << ": " << state.what();
106 break;
107 case core::socket::State::FATAL:
108 VLOG(1) << instanceName << ": " << socketAddress.toString() << ": " << state.what();
109 break;
110 }
111 });
112 }
113
114 return WebApp::start();
115}
#define VLOG(level)
Definition Logger.h:164
static void init(int argc, char *argv[])
Definition WebApp.cpp:56
static int start(const utils::Timeval &timeOut={LONG_MAX, 0})
Definition WebApp.cpp:60
std::string getHtmlRoot()
Definition ConfigWWW.cpp:65

References logger::LogMessage::LogMessage().

Here is the call graph for this function: