aboutsummaryrefslogtreecommitdiff
path: root/zenserver/monitoring/httpstatus.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-10-05 18:10:19 +0200
committerStefan Boberg <[email protected]>2021-10-05 18:10:19 +0200
commit09fa320db4c7727c04eb88f5d19c4c1a3b2189e8 (patch)
tree0d0649b08d8ee479287e8ef4cc6f2507a74f9ed5 /zenserver/monitoring/httpstatus.cpp
parenthttp: Exclude iothreadpool from compilation on non-Windows (diff)
parentPass logger from Zen client to session instead from spdlog registry. (diff)
downloadzen-09fa320db4c7727c04eb88f5d19c4c1a3b2189e8.tar.xz
zen-09fa320db4c7727c04eb88f5d19c4c1a3b2189e8.zip
Merge branch 'main' of https://github.com/EpicGames/zen into main
Diffstat (limited to 'zenserver/monitoring/httpstatus.cpp')
-rw-r--r--zenserver/monitoring/httpstatus.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/zenserver/monitoring/httpstatus.cpp b/zenserver/monitoring/httpstatus.cpp
new file mode 100644
index 000000000..e12662b1c
--- /dev/null
+++ b/zenserver/monitoring/httpstatus.cpp
@@ -0,0 +1,50 @@
+// Copyright Epic Games, Inc. All Rights Reserved.
+
+#include "httpstatus.h"
+
+namespace zen {
+
+HttpStatusService::HttpStatusService() : m_Log(logging::Get("status"))
+{
+}
+
+HttpStatusService::~HttpStatusService()
+{
+}
+
+const char*
+HttpStatusService::BaseUri() const
+{
+ return "/status/";
+}
+
+void
+HttpStatusService::RegisterHandler(std::string_view Id, IHttpStatusProvider& Provider)
+{
+ RwLock::ExclusiveLockScope _(m_Lock);
+ m_Providers.insert_or_assign(std::string(Id), &Provider);
+}
+
+void
+HttpStatusService::HandleRequest(HttpServerRequest& Request)
+{
+ using namespace std::literals;
+
+ std::string_view Key = Request.RelativeUri();
+
+ switch (Request.RequestVerb())
+ {
+ case HttpVerb::kHead:
+ case HttpVerb::kGet:
+ if (auto It = m_Providers.find(std::string{Key}); It != end(m_Providers))
+ {
+ return It->second->HandleStatusRequest(Request);
+ }
+
+ [[fallthrough]];
+ default:
+ return;
+ }
+}
+
+} // namespace zen