aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/frontend/frontend.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2023-05-31 14:16:46 -0400
committerStefan Boberg <[email protected]>2023-05-31 14:16:46 -0400
commit32fcdc3dc00f921b55115902559529bc4aedc595 (patch)
tree20fc53cbb54ecb3a5d72c772a8906f28d149a644 /src/zenserver/frontend/frontend.cpp
parentAdded Sentry debug information note to CHANGELOG.md (diff)
downloadzen-32fcdc3dc00f921b55115902559529bc4aedc595.tar.xz
zen-32fcdc3dc00f921b55115902559529bc4aedc595.zip
Enable front-end serving in release mode
Front-end can now be served from a development directory in release mode as well as debug if there's no zipfs attached
Diffstat (limited to 'src/zenserver/frontend/frontend.cpp')
-rw-r--r--src/zenserver/frontend/frontend.cpp65
1 files changed, 39 insertions, 26 deletions
diff --git a/src/zenserver/frontend/frontend.cpp b/src/zenserver/frontend/frontend.cpp
index 149d97924..b743ca939 100644
--- a/src/zenserver/frontend/frontend.cpp
+++ b/src/zenserver/frontend/frontend.cpp
@@ -4,6 +4,8 @@
#include <zencore/endian.h>
#include <zencore/filesystem.h>
+#include <zencore/fmtutils.h>
+#include <zencore/logging.h>
#include <zencore/string.h>
ZEN_THIRD_PARTY_INCLUDES_START
@@ -23,50 +25,61 @@ HttpFrontendService::HttpFrontendService(std::filesystem::path Directory) : m_Di
IoBuffer SelfBuffer = IoBufferBuilder::MakeFromFile(SelfPath);
m_ZipFs = ZipFs(std::move(SelfBuffer));
-#if ZEN_BUILD_DEBUG
- if (!Directory.empty())
+ if (m_Directory.empty() && !m_ZipFs)
{
- return;
- }
+ // Probe for development layout
- std::error_code ErrorCode;
- auto Path = SelfPath;
- while (Path.has_parent_path())
- {
- auto ParentPath = Path.parent_path();
- if (ParentPath == Path)
- {
- break;
- }
- if (std::filesystem::is_regular_file(ParentPath / "xmake.lua", ErrorCode))
+ std::error_code ErrorCode;
+ std::filesystem::path Path = SelfPath;
+
+ while (Path.has_parent_path())
{
- if (ErrorCode)
+ std::filesystem::path ParentPath = Path.parent_path();
+ if (ParentPath == Path)
{
break;
}
-
- auto HtmlDir = ParentPath / "zenserver" / "frontend" / "html";
- if (std::filesystem::is_directory(HtmlDir, ErrorCode))
+ if (std::filesystem::is_regular_file(ParentPath / "xmake.lua", ErrorCode))
{
- m_Directory = HtmlDir;
+ if (ErrorCode)
+ {
+ break;
+ }
+
+ std::filesystem::path HtmlDir = ParentPath / "src" / "zenserver" / "frontend" / "html";
+
+ if (std::filesystem::is_directory(HtmlDir, ErrorCode))
+ {
+ m_Directory = HtmlDir;
+ }
+ break;
}
- break;
+ Path = ParentPath;
}
- Path = ParentPath;
- };
-#endif
+ }
+
+ if (m_ZipFs)
+ {
+ ZEN_INFO("front-end is served from embedded zip");
+ }
+ else if (!m_Directory.empty())
+ {
+ ZEN_INFO("front-end is served from '{}'", m_Directory);
+ }
+ else
+ {
+ ZEN_INFO("front-end is NOT AVAILABLE");
+ }
}
-////////////////////////////////////////////////////////////////////////////////
HttpFrontendService::~HttpFrontendService()
{
}
-////////////////////////////////////////////////////////////////////////////////
const char*
HttpFrontendService::BaseUri() const
{
- return "/dashboard"; // in order to use the root path we need to remove HttpAddUrlToUrlGroup in HttpSys.cpp
+ return "/dashboard/"; // in order to use the root path we need to remove HttpAddUrlToUrlGroup in HttpSys.cpp
}
////////////////////////////////////////////////////////////////////////////////