2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
42#include "apps/http/model/servers.h"
43#include "express/middleware/StaticMiddleware.h"
44#include "net/config/ConfigSection.hpp"
46#ifndef DOXYGEN_SHOULD_SKIP_THIS
48#include "log/Logger.h"
52using namespace express;
54int main(
int argc,
char* argv[]) {
55 using WebApp = apps::http::STREAM::WebApp;
56 using SocketAddress = WebApp::SocketAddress;
58 const WebApp webApp(apps::http::STREAM::getWebApp(
"httpserver"));
60 net::
config::ConfigSection configWeb = net::
config::ConfigSection(&webApp.getConfig(),
"www",
"Web behavior of httpserver");
61 CLI::Option* htmlRoot = configWeb.addOption(
"--html-root",
"HTML root directory",
"path",
"");
62 configWeb.required(htmlRoot);
63 WebApp::init(argc, argv);
65 webApp.use(express::middleware::StaticMiddleware(htmlRoot->as<std::string>()));
67#if (STREAM_TYPE == TLS)
77 [instanceName = webApp.getConfig().getInstanceName()](
const SocketAddress& socketAddress,
const core::socket::State& state) {
79 case core::socket::State::OK:
80 VLOG(1) << instanceName <<
": listening on '" << socketAddress.toString() <<
"'";
82 case core::socket::State::DISABLED:
83 VLOG(1) << instanceName <<
": disabled";
85 case core::socket::State::ERROR:
86 LOG(ERROR) << instanceName <<
": " << socketAddress.toString() <<
": " << state.what();
88 case core::socket::State::FATAL:
89 LOG(FATAL) << instanceName <<
": " << socketAddress.toString() <<
": " << state.what();
94 return WebApp::start();
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
int main(int argc, char *argv[])