diff options
Diffstat (limited to 'zenserver/monitoring/httpstatus.cpp')
| -rw-r--r-- | zenserver/monitoring/httpstatus.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/zenserver/monitoring/httpstatus.cpp b/zenserver/monitoring/httpstatus.cpp index c18bf6c1f..e12662b1c 100644 --- a/zenserver/monitoring/httpstatus.cpp +++ b/zenserver/monitoring/httpstatus.cpp @@ -15,7 +15,14 @@ HttpStatusService::~HttpStatusService() const char* HttpStatusService::BaseUri() const { - return "/statUs/"; + 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 @@ -23,10 +30,20 @@ HttpStatusService::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->HandleStatusRequest(Request); + } + + [[fallthrough]]; + default: + return; } } |