From cceed531be3fc89f034e79a599a72e28ebe7d32b Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Mon, 4 Oct 2021 15:24:53 +0200 Subject: monitoring: added stubs for /stats and /status endpoints this is a tactical check-in to allow me to merge some other changes --- zenserver/monitoring/httpstats.cpp | 33 +++++++++++++++++++++++++++++++++ zenserver/monitoring/httpstats.h | 26 ++++++++++++++++++++++++++ zenserver/monitoring/httpstatus.cpp | 33 +++++++++++++++++++++++++++++++++ zenserver/monitoring/httpstatus.h | 26 ++++++++++++++++++++++++++ zenserver/zenserver.vcxproj | 7 +++++++ zenserver/zenserver.vcxproj.filters | 7 +++++++ 6 files changed, 132 insertions(+) create mode 100644 zenserver/monitoring/httpstats.cpp create mode 100644 zenserver/monitoring/httpstats.h create mode 100644 zenserver/monitoring/httpstatus.cpp create mode 100644 zenserver/monitoring/httpstatus.h 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 +#include + +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 +#include + +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 diff --git a/zenserver/zenserver.vcxproj b/zenserver/zenserver.vcxproj index 335786fbf..7fad477a1 100644 --- a/zenserver/zenserver.vcxproj +++ b/zenserver/zenserver.vcxproj @@ -108,8 +108,12 @@ + + + + @@ -134,6 +138,9 @@ + + + diff --git a/zenserver/zenserver.vcxproj.filters b/zenserver/zenserver.vcxproj.filters index 1c5b17fee..04e639a33 100644 --- a/zenserver/zenserver.vcxproj.filters +++ b/zenserver/zenserver.vcxproj.filters @@ -41,6 +41,10 @@ experimental + + + + @@ -77,6 +81,9 @@ experimental + + + -- cgit v1.2.3