46int main(
int argc,
char* argv[]) {
47 utils::Config::addStringOption(
"--web-root",
"Root directory of the web site",
"[path]");
52 const legacy::in6::WebApp legacyApp(
"legacy");
54 const Router& router1 = middleware::VHost(
"localhost:8080");
56 const Router& ba = middleware::BasicAuthentication(
"voc",
"pentium5",
"Authenticate yourself with username and password");
57 ba.use(middleware::StaticMiddleware(utils::Config::getStringOptionValue(
"--web-root")));
60 legacyApp.use(router1);
62 const Router& router2 = middleware::VHost(
"ceres.home.vchrist.at:8080");
64 res->send(
"Hello! I am VHOST ceres.home.vchrist.at.");
66 legacyApp.use(router2);
69 res->status(404).send(
"The requested resource is not found.");
72 legacyApp.listen(8080,
73 [instanceName = legacyApp.getConfig().getInstanceName()](
const legacy::in6::WebApp::SocketAddress& socketAddress,
74 const core::socket::State& state) {
76 case core::socket::State::OK:
77 VLOG(1) << instanceName <<
": listening on '" << socketAddress.toString() <<
"'";
79 case core::socket::State::DISABLED:
80 VLOG(1) << instanceName <<
": disabled";
82 case core::socket::State::ERROR:
83 LOG(ERROR) << instanceName <<
": " << socketAddress.toString() <<
": " << state.what();
85 case core::socket::State::FATAL:
86 LOG(FATAL) << instanceName <<
": " << socketAddress.toString() <<
": " << state.what();
92 const express::tls::in6::WebApp tlsApp(
"tls");
94 const Router& vh1 = middleware::VHost(
"localhost:8088");
95 vh1.use(getRouter(utils::Config::getStringOptionValue(
"--web-root")));
98 const Router& vh2 = middleware::VHost(
"ceres.home.vchrist.at:8088");
100 res->send(
"Hello! I am VHOST ceres.home.vchrist.at.");
106 res->status(404).send(
"The requested resource is not found.");
109 tlsApp.listen(8088, [](
const legacy::in6::WebApp::SocketAddress& socketAddress,
const core::socket::State& state) {
111 case core::socket::State::OK:
112 VLOG(1) <<
"tls: listening on '" << socketAddress.toString() <<
"'"
115 case core::socket::State::DISABLED:
116 VLOG(1) <<
"tls: disabled";
118 case core::socket::State::ERROR:
119 VLOG(1) <<
"tls: error occurred";
121 case core::socket::State::FATAL:
122 VLOG(1) <<
"tls: fatal error occurred";