Add support for redis with password, introduced new arguments with -
This commit is contained in:
1 parent
c10e0a17cf
commit
22862a2795
4 files changed
+76
-33
No files matched your search
+7
-15
@@ -10,25 +10,17 @@ namespace {
|
||||
QHttpServerResponse serveHtmlWithPlaceholders(const QString &filePath, const QMap<QString, QString> &placeholders);
|
||||
} // namespace
|
||||
|
||||
WebServer::WebServer(const QString &identity, const QString &url, QObject *parent) :
|
||||
WebServer::WebServer(const QString &identity,
|
||||
#ifdef FEATURE_REDIS
|
||||
redisAsyncContext *redis,
|
||||
#endif
|
||||
QObject *parent) :
|
||||
QObject{parent},
|
||||
m_identity{identity}
|
||||
{
|
||||
#ifdef FEATURE_REDIS
|
||||
m_redis = redisAsyncConnect("localhost", 6379);
|
||||
|
||||
if (m_redis->err)
|
||||
qFatal("error with redis: %s", m_redis->errstr);
|
||||
|
||||
m_redisAdapter.setContext(m_redis);
|
||||
|
||||
redisAsyncCommand(m_redis, NULL, NULL, "SET %s %s",
|
||||
QString{"traefik/http/services/proxyjs_%0/loadbalancer/servers/0/url"}.arg(m_identity).toUtf8().constData(),
|
||||
url.toUtf8().constData());
|
||||
|
||||
qDebug() << "redis connected";
|
||||
, m_redis{redis}
|
||||
#endif
|
||||
|
||||
{
|
||||
m_server.route("/", [&]() {
|
||||
return serveHtmlWithPlaceholders(":/lspjs/index.html", {
|
||||
{"identity", identity}
|
||||
|
||||
Reference in new issue
Block a user