diff options
| author | Stefan Boberg <[email protected]> | 2026-02-19 20:51:32 +0100 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2026-02-19 20:51:32 +0100 |
| commit | f29a15588a72a5d3ace7e615493b09451a12aaf9 (patch) | |
| tree | 9d325fe2bd6a8283c336b4cc0939a6ea9d279ee1 /src/zenhttp/httpserver.cpp | |
| parent | fix orchestrator-to-compute node link (diff) | |
| download | zen-f29a15588a72a5d3ace7e615493b09451a12aaf9.tar.xz zen-f29a15588a72a5d3ace7e615493b09451a12aaf9.zip | |
added HttpServer::GetServiceUri
intended to be used to get an externally accessible URI to a given service (or the root endpoint if `nullptr` is specified)
Diffstat (limited to 'src/zenhttp/httpserver.cpp')
| -rw-r--r-- | src/zenhttp/httpserver.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/zenhttp/httpserver.cpp b/src/zenhttp/httpserver.cpp index f2fe4738f..d6dfb347f 100644 --- a/src/zenhttp/httpserver.cpp +++ b/src/zenhttp/httpserver.cpp @@ -23,6 +23,7 @@ #include <zencore/logging.h> #include <zencore/stream.h> #include <zencore/string.h> +#include <zencore/system.h> #include <zencore/testing.h> #include <zencore/thread.h> #include <zenhttp/packageformat.h> @@ -1014,7 +1015,21 @@ HttpRequestRouter::HandleRequest(zen::HttpServerRequest& Request) int HttpServer::Initialize(int BasePort, std::filesystem::path DataDir) { - return OnInitialize(BasePort, std::move(DataDir)); + m_EffectivePort = OnInitialize(BasePort, std::move(DataDir)); + return m_EffectivePort; +} + +std::string +HttpServer::GetServiceUri(const HttpService* Service) const +{ + if (Service) + { + return fmt::format("http://{}:{}{}", GetMachineName(), m_EffectivePort, Service->BaseUri()); + } + else + { + return fmt::format("http://{}:{}", GetMachineName(), m_EffectivePort); + } } void |