diff options
Diffstat (limited to 'zenhttp/httpserver.cpp')
| -rw-r--r-- | zenhttp/httpserver.cpp | 52 |
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; + } } ////////////////////////////////////////////////////////////////////////// |