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 "express/legacy/in6/WebApp.h"
43#include "express/middleware/StaticMiddleware.h"
44#include "express/middleware/VHost.h"
45#include "express/tls/in6/WebApp.h"
46#include "utils/Config.h"
48#ifndef DOXYGEN_SHOULD_SKIP_THIS
50#include "log/Logger.h"
56using namespace express;
61 router.use(
middleware::StaticMiddleware(webRoot));
66int main(
int argc,
char* argv[]) {
81 if (req->
query("how").empty()) {
83 }
else if (req->
query("how") ==
"route") {
85 }
else if (req->
query("how") ==
"router") {
90 res->
send("Hello! I am VHOST jupiter.home.vchrist.at.");
97 if (req->
query("how").empty()) {
99 }
else if (req->
query("how") ==
"route") {
101 }
else if (req->
query("how") ==
"router") {
106 res->
send("Hello! I am VHOST atlas.home.vchrist.at.");
109 res->
send("Hello, next route on atlas.home.vchrist.at");
112 res->
send("Test Route on VHOST atlas.home.vchrist.at.");
122 const core::socket::
State& state) {
125 VLOG(1) << instanceName <<
" listening on '" << socketAddress
.toString() <<
"'";
128 VLOG(1) << instanceName <<
" disabled";
131 LOG(ERROR) << instanceName <<
" " << socketAddress
.toString() <<
": " << state
.what();
134 LOG(FATAL) << instanceName <<
" " << socketAddress
.toString() <<
": " << state
.what();
150 if (req->
query("how").empty()) {
152 }
else if (req->
query("how") ==
"route") {
154 }
else if (req->
query("how") ==
"router") {
159 res->
send("Hello! I am VHOST atlas.home.vchrist.at.");
166 if (req->
query("how").empty()) {
168 }
else if (req->
query("how") ==
"route") {
170 }
else if (req->
query("how") ==
"router") {
175 res->
send("Hello! I am VHOST ceres.home.vchrist.at.");
178 res->
send("Hello, next route on ceres.home.vchrist.at");
181 res->
send("Test Route on VHOST ceres.home.vchrist.at.");
191 const core::socket::
State& state) {
194 VLOG(1) << instanceName <<
" listening on '" << socketAddress
.toString() <<
"'";
197 VLOG(1) << instanceName <<
" disabled";
200 LOG(ERROR) << instanceName <<
" " << socketAddress
.toString() <<
": " << state
.what();
203 LOG(FATAL) << instanceName <<
" " << socketAddress
.toString() <<
": " << state
.what();
208 tlsApp
.getConfig().setCert("/home/voc/projects/snodec/snode.c/certs/wildcard.home.vchrist.at_-_snode.c_-_server.pem");
210 "/home/voc/projects/snodec/snode.c/certs/Volker_Christian_-_Web_-_snode.c_-_server.key.encrypted.pem");
#define APPLICATION(req, res)
#define MIDDLEWARE(req, res, next)
Config & getConfig() const
static constexpr int DISABLED
static constexpr int ERROR
static constexpr int FATAL
void operator()(const std::string &how="") const
const std::string & query(const std::string &key) const
void send(const std::string &chunk)
Response & status(int status)
WebAppT(const std::string &name)
static void init(int argc, char *argv[])
static int start(const utils::Timeval &timeOut={LONG_MAX, 0})
const std::string & getInstanceName() const
ConfigTls & setCert(const std::string &cert)
ConfigTls & setCertKey(const std::string &certKey)
ConfigTls & setCertKeyPassword(const std::string &certKeyPassword)
std::string toString(bool expanded=true) const override
const Super & listen(uint16_t port, const std::function< void(const SocketAddress &, core::socket::State)> &onStatus) const
static CLI::Option * addStringOption(const std::string &name, const std::string &description, const std::string &typeName)
static std::string getStringOptionValue(const std::string &name)
int main(int argc, char *argv[])
WebAppT< web::http::legacy::in6::Server > WebApp
WebAppT< web::http::tls::in6::Server > WebApp
Router getRouter(const std::string &webRoot)