From f6ee71a52da990b3bdc41bf56fcef87b30ca964b Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Mon, 27 Sep 2021 11:31:43 +0200 Subject: Added simple compact binary endpoint for JSON testing --- zenserver/testing/httptest.cpp | 11 +++++++++++ zenserver/testing/httptest.h | 5 ++++- 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'zenserver/testing') diff --git a/zenserver/testing/httptest.cpp b/zenserver/testing/httptest.cpp index c4fd6003c..18d63a6ef 100644 --- a/zenserver/testing/httptest.cpp +++ b/zenserver/testing/httptest.cpp @@ -2,6 +2,7 @@ #include "httptest.h" +#include #include namespace zen { @@ -13,6 +14,16 @@ HttpTestingService::HttpTestingService() [this](HttpRouterRequest& Req) { Req.ServerRequest().WriteResponse(HttpResponseCode::OK); }, HttpVerb::kGet); + m_Router.RegisterRoute( + "json", + [this](HttpRouterRequest& Req) { + CbObjectWriter Obj; + Obj.AddBool("ok", true); + Obj.AddInteger("counter", ++m_Counter); + Req.ServerRequest().WriteResponse(HttpResponseCode::OK, Obj.Save()); + }, + HttpVerb::kGet); + m_Router.RegisterRoute( "echo", [this](HttpRouterRequest& Req) { diff --git a/zenserver/testing/httptest.h b/zenserver/testing/httptest.h index b445fb450..f55780d05 100644 --- a/zenserver/testing/httptest.h +++ b/zenserver/testing/httptest.h @@ -5,6 +5,8 @@ #include #include +#include + namespace zen { /** @@ -37,7 +39,8 @@ public: }; private: - HttpRequestRouter m_Router; + HttpRequestRouter m_Router; + std::atomic m_Counter{0}; RwLock m_RwLock; std::unordered_map> m_HandlerMap; -- cgit v1.2.3