aboutsummaryrefslogtreecommitdiff
path: root/zenserver/testing/httptest.cpp
diff options
context:
space:
mode:
authorMartin Ridgers <[email protected]>2021-10-07 08:29:50 +0200
committerMartin Ridgers <[email protected]>2021-10-07 08:29:50 +0200
commit03232621d183f22e12e798a753e4a606763e63d6 (patch)
tree5701d202392dd4ab947139e4046a44ab9bc6cdf7 /zenserver/testing/httptest.cpp
parentMerged main (diff)
parentOnly enable the MSVC debug output sink for sessions when the --debug mode is ... (diff)
downloadzen-03232621d183f22e12e798a753e4a606763e63d6.tar.xz
zen-03232621d183f22e12e798a753e4a606763e63d6.zip
Merged main
Diffstat (limited to 'zenserver/testing/httptest.cpp')
-rw-r--r--zenserver/testing/httptest.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/zenserver/testing/httptest.cpp b/zenserver/testing/httptest.cpp
index 01866a63b..924546762 100644
--- a/zenserver/testing/httptest.cpp
+++ b/zenserver/testing/httptest.cpp
@@ -4,9 +4,12 @@
#include <zencore/compactbinarybuilder.h>
#include <zencore/compactbinarypackage.h>
+#include <zencore/timer.h>
namespace zen {
+using namespace fmt::literals;
+
HttpTestingService::HttpTestingService()
{
m_Router.RegisterRoute(
@@ -15,6 +18,44 @@ HttpTestingService::HttpTestingService()
HttpVerb::kGet);
m_Router.RegisterRoute(
+ "hello_slow",
+ [this](HttpRouterRequest& Req) {
+ Req.ServerRequest().WriteResponseAsync([this](HttpServerRequest& Request) {
+ Stopwatch Timer;
+ Sleep(1000);
+ Request.WriteResponse(HttpResponseCode::OK,
+ HttpContentType::kText,
+ "hello, took me {}"_format(NiceTimeSpanMs(Timer.GetElapsedTimeMs())));
+ });
+ },
+ HttpVerb::kGet);
+
+ m_Router.RegisterRoute(
+ "hello_veryslow",
+ [this](HttpRouterRequest& Req) {
+ Req.ServerRequest().WriteResponseAsync([this](HttpServerRequest& Request) {
+ Stopwatch Timer;
+ Sleep(60000);
+ Request.WriteResponse(HttpResponseCode::OK,
+ HttpContentType::kText,
+ "hello, took me {}"_format(NiceTimeSpanMs(Timer.GetElapsedTimeMs())));
+ });
+ },
+ HttpVerb::kGet);
+
+ m_Router.RegisterRoute(
+ "hello_throw",
+ [this](HttpRouterRequest& Req) {
+ Req.ServerRequest().WriteResponseAsync([this](HttpServerRequest&) { throw std::runtime_error("intentional error"); });
+ },
+ HttpVerb::kGet);
+
+ m_Router.RegisterRoute(
+ "hello_noresponse",
+ [this](HttpRouterRequest& Req) { Req.ServerRequest().WriteResponseAsync([this](HttpServerRequest&) {}); },
+ HttpVerb::kGet);
+
+ m_Router.RegisterRoute(
"metrics",
[this](HttpRouterRequest& Req) {
metrics::OperationTiming::Scope _(m_TimingStats);