aboutsummaryrefslogtreecommitdiff
path: root/zenserver/monitoring/httpstats.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'zenserver/monitoring/httpstats.cpp')
-rw-r--r--zenserver/monitoring/httpstats.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/zenserver/monitoring/httpstats.cpp b/zenserver/monitoring/httpstats.cpp
index a82cfda50..de04294d0 100644
--- a/zenserver/monitoring/httpstats.cpp
+++ b/zenserver/monitoring/httpstats.cpp
@@ -19,14 +19,31 @@ HttpStatsService::BaseUri() const
}
void
+HttpStatsService::RegisterHandler(std::string_view Id, IHttpStatsProvider& Provider)
+{
+ RwLock::ExclusiveLockScope _(m_Lock);
+ m_Providers.insert_or_assign(std::string(Id), &Provider);
+}
+
+void
HttpStatsService::HandleRequest(HttpServerRequest& Request)
{
using namespace std::literals;
+ std::string_view Key = Request.RelativeUri();
+
switch (Request.RequestVerb())
{
+ case HttpVerb::kHead:
case HttpVerb::kGet:
- return Request.WriteResponse(HttpResponseCode::OK, HttpContentType::kText, u8"OK!"sv);
+ if (auto It = m_Providers.find(std::string{Key}); It != end(m_Providers))
+ {
+ return It->second->HandleStatsRequest(Request);
+ }
+
+ [[fallthrough]];
+ default:
+ return;
}
}