aboutsummaryrefslogtreecommitdiff
path: root/zenhttp/httpserver.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-10-14 19:07:14 +0200
committerGitHub <[email protected]>2021-10-14 19:07:14 +0200
commit2b71d6a8d57c773bc7734b253a1ffd1e47162184 (patch)
treec0c70f9f2f8b9dc895080aac9f7de1140c56ebf0 /zenhttp/httpserver.cpp
parentMerge branch 'main' of https://github.com/EpicGames/zen (diff)
downloadzen-2b71d6a8d57c773bc7734b253a1ffd1e47162184.tar.xz
zen-2b71d6a8d57c773bc7734b253a1ffd1e47162184.zip
asio HTTP implementation (#23)
asio-based HTTP implementation
Diffstat (limited to 'zenhttp/httpserver.cpp')
-rw-r--r--zenhttp/httpserver.cpp52
1 files changed, 46 insertions, 6 deletions
diff --git a/zenhttp/httpserver.cpp b/zenhttp/httpserver.cpp
index 69974ca06..150054c30 100644
--- a/zenhttp/httpserver.cpp
+++ b/zenhttp/httpserver.cpp
@@ -2,9 +2,9 @@
#include <zenhttp/httpserver.h>
+#include "httpasio.h"
#include "httpnull.h"
#include "httpsys.h"
-#include "httpuws.h"
#include <zencore/compactbinary.h>
#include <zencore/compactbinarypackage.h>
@@ -565,16 +565,56 @@ HttpRequestRouter::HandleRequest(zen::HttpServerRequest& Request)
//////////////////////////////////////////////////////////////////////////
+enum class HttpServerClass
+{
+ kHttpAsio,
+ kHttpSys,
+ kHttpNull
+};
+
Ref<HttpServer>
-CreateHttpServer()
+CreateHttpServer(std::string_view ServerClass)
{
-#if 0
- return new HttpUwsServer;
+ using namespace std::literals;
+
+#if 1
+ HttpServerClass Class = HttpServerClass::kHttpAsio;
#elif ZEN_WITH_HTTPSYS
- return new HttpSysServer(std::thread::hardware_concurrency(), /* background worker threads */ 16);
+ HttpServerClass Class = HttpServerClass::kHttpSys;
#else
- return new HttpNullServer;
+ HttpServerClass Class = HttpServerClass::kHttpNull;
+#endif
+
+ if (ServerClass == "asio"sv)
+ {
+ Class = HttpServerClass::kHttpAsio;
+ }
+ else if (ServerClass == "httpsys"sv)
+ {
+ Class = HttpServerClass::kHttpSys;
+ }
+ else if (ServerClass == "null"sv)
+ {
+ Class = HttpServerClass::kHttpNull;
+ }
+
+ switch (Class)
+ {
+ default:
+ case HttpServerClass::kHttpAsio:
+ ZEN_INFO("using asio HTTP server implementation");
+ return new HttpAsioServer();
+
+#if ZEN_WITH_HTTPSYS
+ case HttpServerClass::kHttpSys:
+ ZEN_INFO("using http.sys server implementation");
+ return new HttpSysServer(std::thread::hardware_concurrency(), /* background worker threads */ 16);
#endif
+
+ case HttpServerClass::kHttpNull:
+ ZEN_INFO("using null HTTP server implementation");
+ return new HttpNullServer;
+ }
}
//////////////////////////////////////////////////////////////////////////