diff options
| author | Martin Ridgers <[email protected]> | 2021-10-15 16:04:56 +0200 |
|---|---|---|
| committer | Martin Ridgers <[email protected]> | 2021-10-15 16:04:56 +0200 |
| commit | 402dfddf62d979319038801a926809e33839e096 (patch) | |
| tree | e8a8e99c7f4718a5fcc363245cc19e16a41bea25 /zenhttp/httpserver.cpp | |
| parent | If/def around Windows-only headers (diff) | |
| parent | httpasio: Implemented support for specifying accept type via url suffix (diff) | |
| download | zen-402dfddf62d979319038801a926809e33839e096.tar.xz zen-402dfddf62d979319038801a926809e33839e096.zip | |
Merged main
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; + } } ////////////////////////////////////////////////////////////////////////// |