aboutsummaryrefslogtreecommitdiff
path: root/src/zenhttp/httpserver.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2025-12-11 09:34:24 +0100
committerGitHub Enterprise <[email protected]>2025-12-11 09:34:24 +0100
commit3de9a65cd990f2a4f5395b7e2a094471633eb98b (patch)
treef1640a32fd2b68a8f1b6f77f5ba5c4cbf959cb0b /src/zenhttp/httpserver.cpp
parent5.7.14-pre3 (diff)
downloadzen-3de9a65cd990f2a4f5395b7e2a094471633eb98b.tar.xz
zen-3de9a65cd990f2a4f5395b7e2a094471633eb98b.zip
HTTP server API changes for improved extensibility (#684)
* refactored `HttpServer` so all subclass member functions are proctected, to make it easier to extend base functionality * added API service, can be used to enumerate registered endpoints (at `/api`). Currently only very basic information is provided
Diffstat (limited to 'src/zenhttp/httpserver.cpp')
-rw-r--r--src/zenhttp/httpserver.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/zenhttp/httpserver.cpp b/src/zenhttp/httpserver.cpp
index 1357f1b9b..e529fb76e 100644
--- a/src/zenhttp/httpserver.cpp
+++ b/src/zenhttp/httpserver.cpp
@@ -990,6 +990,49 @@ HttpRequestRouter::HandleRequest(zen::HttpServerRequest& Request)
//////////////////////////////////////////////////////////////////////////
+int
+HttpServer::Initialize(int BasePort, std::filesystem::path DataDir)
+{
+ return OnInitialize(BasePort, std::move(DataDir));
+}
+
+void
+HttpServer::Run(bool IsInteractiveSession)
+{
+ OnRun(IsInteractiveSession);
+}
+
+void
+HttpServer::RequestExit()
+{
+ OnRequestExit();
+}
+void
+HttpServer::Close()
+{
+ OnClose();
+}
+
+void
+HttpServer::RegisterService(HttpService& Service)
+{
+ OnRegisterService(Service);
+ m_KnownServices.push_back(&Service);
+}
+
+void
+HttpServer::EnumerateServices(std::function<void(HttpService& Service)>&& Callback)
+{
+ // This doesn't take a lock because services should only be registered during
+ // server initialization, before it starts accepting requests
+ for (HttpService* Service : m_KnownServices)
+ {
+ Callback(*Service);
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////
+
HttpRpcHandler::HttpRpcHandler()
{
}