first release 0.1.1

This commit is contained in:
2025-05-30 16:44:39 +02:00
parent 3d3264d8d6
commit 71f771b428
9 changed files with 41 additions and 31 deletions

View File

@@ -41,6 +41,12 @@ expected<AppSettings, string> AppSettings::loadAppSettings() {
return unexpected("'services' array in JSON file is empty");
}
if (j.contains("httpPort")) {
settings.httpPort = j["httpPort"].get<int>();
} else {
settings.httpPort = {};
}
return settings;
}

View File

@@ -5,6 +5,7 @@
#include <string>
#include <expected>
#include <optional>
#include <cstdint>
struct Service {
std::string name;
@@ -17,6 +18,7 @@ struct AppSettings {
std::optional<std::string> getId(std::string_view name);
std::vector<Service> services;
std::optional<uint16_t> httpPort;
};
#endif // JSON_SETTINGS_H

View File

@@ -3,6 +3,7 @@
#include <sstream>
#include <cstdlib>
#include <string>
#include <print>
#include <optional>
#include "json_settings.h"
#include "htmx_helper.h"
@@ -68,5 +69,19 @@ int main() {
return crow::response{row.htmx()};
});
app.port(8080).multithreaded().run();
const uint16_t defaultPort = 3010;
uint16_t httpPort = defaultPort;
{
auto opt_settings = AppSettings::loadAppSettings();
if (opt_settings.has_value()){
auto& settings = opt_settings.value();
httpPort = settings.httpPort.value_or(defaultPort);
} else {
CROW_LOG_ERROR << "failed to load settings : " << opt_settings.error();
}
}
app.loglevel(crow::LogLevel::INFO);
app.port(httpPort).multithreaded().run();
}