diff options
| author | Stefan Boberg <[email protected]> | 2021-09-27 11:31:43 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-09-27 11:31:43 +0200 |
| commit | f6ee71a52da990b3bdc41bf56fcef87b30ca964b (patch) | |
| tree | 0719e6deaea27d24a1f08441643927625098c1f9 /zenserver/testing/httptest.cpp | |
| parent | Compact binary to JSON (#12) (diff) | |
| download | zen-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.cpp | 11 |
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(); |