Ui serving
All checks were successful
CI / React UI Build (push) Successful in 11s
CI / Native Windows Build And Tests (push) Successful in 2m55s
CI / Windows Release Package (push) Successful in 3m21s

This commit is contained in:
Aiden
2026-05-12 13:25:34 +10:00
parent bc690e2a87
commit b44504500a
7 changed files with 118 additions and 4 deletions

View File

@@ -70,6 +70,7 @@ public:
HttpControlServer& operator=(const HttpControlServer&) = delete;
bool Start(
const std::filesystem::path& uiRoot,
const std::filesystem::path& docsRoot,
HttpControlServerConfig config,
HttpControlServerCallbacks callbacks,
@@ -80,6 +81,7 @@ public:
unsigned short Port() const { return mPort; }
void SetCallbacksForTest(HttpControlServerCallbacks callbacks);
void SetRootsForTest(const std::filesystem::path& uiRoot, const std::filesystem::path& docsRoot);
HttpResponse RouteRequestForTest(const HttpRequest& request) const;
static bool ParseHttpRequest(const std::string& rawRequest, HttpRequest& request);
@@ -94,14 +96,18 @@ private:
HttpResponse ServePost(const HttpRequest& request) const;
HttpResponse ServeOpenApiSpec() const;
HttpResponse ServeSwaggerDocs() const;
HttpResponse ServeUiAsset(const std::string& relativePath) const;
std::string LoadTextFile(const std::filesystem::path& path) const;
static HttpResponse JsonResponse(const std::string& status, const std::string& body);
static HttpResponse TextResponse(const std::string& status, const std::string& body);
static HttpResponse HtmlResponse(const std::string& status, const std::string& body);
static std::string ActionResponse(bool ok, const std::string& error = std::string());
static std::string GuessContentType(const std::filesystem::path& path);
static bool IsSafeRelativePath(const std::filesystem::path& path);
static std::string ToLower(std::string text);
std::filesystem::path mUiRoot;
std::filesystem::path mDocsRoot;
HttpControlServerConfig mConfig;
HttpControlServerCallbacks mCallbacks;