aboutsummaryrefslogtreecommitdiff
path: root/zenserver/testing/httptest.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-09-08 21:38:20 +0200
committerStefan Boberg <[email protected]>2021-09-08 21:38:20 +0200
commit74eeda8aa9c67ca9820b8f7dd98bc2da3f97748a (patch)
treed3b55f48abd50665eb4ec7f5022885061b2f604a /zenserver/testing/httptest.cpp
parentLog spawned process name (diff)
downloadzen-74eeda8aa9c67ca9820b8f7dd98bc2da3f97748a.tar.xz
zen-74eeda8aa9c67ca9820b8f7dd98bc2da3f97748a.zip
Introduced dedicated HTTP testing service, used during development to exercise the server framework
Diffstat (limited to 'zenserver/testing/httptest.cpp')
-rw-r--r--zenserver/testing/httptest.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/zenserver/testing/httptest.cpp b/zenserver/testing/httptest.cpp
new file mode 100644
index 000000000..0639c2b53
--- /dev/null
+++ b/zenserver/testing/httptest.cpp
@@ -0,0 +1,48 @@
+// Copyright Epic Games, Inc. All Rights Reserved.
+
+#include "httptest.h"
+
+namespace zen {
+
+HttpTestingService::HttpTestingService()
+{
+ m_Router.RegisterRoute(
+ "hello",
+ [this](HttpRouterRequest& Req) { Req.ServerRequest().WriteResponse(HttpResponse::OK); },
+ HttpVerb::kGet);
+
+ m_Router.RegisterRoute(
+ "echo",
+ [this](HttpRouterRequest& Req) {
+ IoBuffer Body = Req.ServerRequest().ReadPayload();
+ Req.ServerRequest().WriteResponse(HttpResponse::OK, HttpContentType::kBinary, Body);
+ },
+ HttpVerb::kPost);
+
+ m_Router.RegisterRoute("package", m_PackageHandler);
+}
+
+HttpTestingService::~HttpTestingService()
+{
+}
+
+const char*
+HttpTestingService::BaseUri() const
+{
+ return "/testing/";
+}
+
+void
+HttpTestingService::HandleRequest(HttpServerRequest& Request)
+{
+ m_Router.HandleRequest(Request);
+}
+
+void
+HttpTestingService::PackageHandler::HandleRequest(HttpRouterRequest& Req)
+{
+ IoBuffer Body = Req.ServerRequest().ReadPayload();
+ Req.ServerRequest().WriteResponse(HttpResponse::OK, HttpContentType::kBinary, Body);
+}
+
+} // namespace zen