diff options
| author | Stefan Boberg <[email protected]> | 2021-10-04 15:24:53 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-10-04 15:25:33 +0200 |
| commit | cceed531be3fc89f034e79a599a72e28ebe7d32b (patch) | |
| tree | b53c473c3d9899bc97b0b90336882f37f8bcfcf3 /zenserver/monitoring | |
| parent | clang-format (diff) | |
| download | zen-cceed531be3fc89f034e79a599a72e28ebe7d32b.tar.xz zen-cceed531be3fc89f034e79a599a72e28ebe7d32b.zip | |
monitoring: added stubs for /stats and /status endpoints
this is a tactical check-in to allow me to merge some other changes
Diffstat (limited to 'zenserver/monitoring')
| -rw-r--r-- | zenserver/monitoring/httpstats.cpp | 33 | ||||
| -rw-r--r-- | zenserver/monitoring/httpstats.h | 26 | ||||
| -rw-r--r-- | zenserver/monitoring/httpstatus.cpp | 33 | ||||
| -rw-r--r-- | zenserver/monitoring/httpstatus.h | 26 |
4 files changed, 118 insertions, 0 deletions
diff --git a/zenserver/monitoring/httpstats.cpp b/zenserver/monitoring/httpstats.cpp new file mode 100644 index 000000000..a82cfda50 --- /dev/null +++ b/zenserver/monitoring/httpstats.cpp @@ -0,0 +1,33 @@ +// Copyright Epic Games, Inc. All Rights Reserved. + +#include "httpstats.h" + +namespace zen { + +HttpStatsService::HttpStatsService() : m_Log(logging::Get("stats")) +{ +} + +HttpStatsService::~HttpStatsService() +{ +} + +const char* +HttpStatsService::BaseUri() const +{ + return "/stats/"; +} + +void +HttpStatsService::HandleRequest(HttpServerRequest& Request) +{ + using namespace std::literals; + + switch (Request.RequestVerb()) + { + case HttpVerb::kGet: + return Request.WriteResponse(HttpResponseCode::OK, HttpContentType::kText, u8"OK!"sv); + } +} + +} // namespace zen diff --git a/zenserver/monitoring/httpstats.h b/zenserver/monitoring/httpstats.h new file mode 100644 index 000000000..9da48233b --- /dev/null +++ b/zenserver/monitoring/httpstats.h @@ -0,0 +1,26 @@ +// Copyright Epic Games, Inc. All Rights Reserved. + +#pragma once + +#include <zenhttp/httpserver.h> +#include <zencore/logging.h> + +namespace zen { + +class HttpStatsService : public HttpService +{ +public: + HttpStatsService(); + ~HttpStatsService(); + + virtual const char* BaseUri() const override; + virtual void HandleRequest(HttpServerRequest& Request) override; + +private: + spdlog::logger& m_Log; + HttpRequestRouter m_Router; + + inline spdlog::logger& Log() { return m_Log; } +}; + +} // namespace zen
\ No newline at end of file diff --git a/zenserver/monitoring/httpstatus.cpp b/zenserver/monitoring/httpstatus.cpp new file mode 100644 index 000000000..c18bf6c1f --- /dev/null +++ b/zenserver/monitoring/httpstatus.cpp @@ -0,0 +1,33 @@ +// 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::HandleRequest(HttpServerRequest& Request) +{ + using namespace std::literals; + + switch (Request.RequestVerb()) + { + case HttpVerb::kGet: + return Request.WriteResponse(HttpResponseCode::OK, HttpContentType::kText, u8"OK!"sv); + } +} + +} // namespace zen diff --git a/zenserver/monitoring/httpstatus.h b/zenserver/monitoring/httpstatus.h new file mode 100644 index 000000000..f5c6bd616 --- /dev/null +++ b/zenserver/monitoring/httpstatus.h @@ -0,0 +1,26 @@ +// Copyright Epic Games, Inc. All Rights Reserved. + +#pragma once + +#include <zenhttp/httpserver.h> +#include <zencore/logging.h> + +namespace zen { + +class HttpStatusService : public HttpService +{ +public: + HttpStatusService(); + ~HttpStatusService(); + + virtual const char* BaseUri() const override; + virtual void HandleRequest(HttpServerRequest& Request) override; + +private: + spdlog::logger& m_Log; + HttpRequestRouter m_Router; + + inline spdlog::logger& Log() { return m_Log; } +}; + +} // namespace zen
\ No newline at end of file |