aboutsummaryrefslogtreecommitdiff
path: root/zenserver/testing/httptest.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-09-27 11:31:43 +0200
committerStefan Boberg <[email protected]>2021-09-27 11:31:43 +0200
commitf6ee71a52da990b3bdc41bf56fcef87b30ca964b (patch)
tree0719e6deaea27d24a1f08441643927625098c1f9 /zenserver/testing/httptest.cpp
parentCompact binary to JSON (#12) (diff)
downloadzen-f6ee71a52da990b3bdc41bf56fcef87b30ca964b.tar.xz
zen-f6ee71a52da990b3bdc41bf56fcef87b30ca964b.zip
Added simple compact binary endpoint for JSON testing
Diffstat (limited to 'zenserver/testing/httptest.cpp')
-rw-r--r--zenserver/testing/httptest.cpp11
1 files changed, 11 insertions, 0 deletions
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 <zencore/compactbinarybuilder.h>
#include <zencore/compactbinarypackage.h>
namespace zen {
@@ -14,6 +15,16 @@ HttpTestingService::HttpTestingService()
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) {
IoBuffer Body = Req.ServerRequest().ReadPayload();