32int main(
int argc,
char* argv[]) {
33 using WebApp = apps::http::STREAM::WebApp;
34 using SocketAddress = WebApp::SocketAddress;
36 const WebApp webApp(apps::http::STREAM::getWebApp(
"httpserver"));
38 net::
config::ConfigSection configWeb = net::config::ConfigSection(&webApp.getConfig(),
"www",
"Web behavior of httpserver");
39 CLI::Option* htmlRoot = configWeb.addOption(
"--html-root",
"HTML root directory",
"path",
"");
40 configWeb.required(htmlRoot);
41 WebApp::init(argc, argv);
43 webApp.use(express::middleware::StaticMiddleware(htmlRoot->as<std::string>()));
45#if (STREAM_TYPE == TLS)
55 [instanceName = webApp.getConfig().getInstanceName()](
const SocketAddress& socketAddress,
const core::socket::State& state) {
57 case core::socket::State::OK:
58 VLOG(1) << instanceName <<
": listening on '" << socketAddress.toString() <<
"'";
60 case core::socket::State::DISABLED:
61 VLOG(1) << instanceName <<
": disabled";
63 case core::socket::State::ERROR:
64 LOG(ERROR) << instanceName <<
": " << socketAddress.toString() <<
": " << state.what();
66 case core::socket::State::FATAL:
67 LOG(FATAL) << instanceName <<
": " << socketAddress.toString() <<
": " << state.what();
72 return WebApp::start();