diff options
| author | Stefan Boberg <[email protected]> | 2021-09-09 13:58:37 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-09-09 13:58:37 +0200 |
| commit | 565f08ec3327c6cdad2eeb2fac1f45a1a24b95cf (patch) | |
| tree | dfce4e0b8cbbafb416c9a7ce7e38a3d25fbdde48 /zencore/httpsys.cpp | |
| parent | Moved http.sys server implementation into dedicated source files (diff) | |
| download | zen-565f08ec3327c6cdad2eeb2fac1f45a1a24b95cf.tar.xz zen-565f08ec3327c6cdad2eeb2fac1f45a1a24b95cf.zip | |
Made HttpServer an abstract interface, and moved remaining implementation specifics for http.sys into the dedicated cpp/h source files
Diffstat (limited to 'zencore/httpsys.cpp')
| -rw-r--r-- | zencore/httpsys.cpp | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/zencore/httpsys.cpp b/zencore/httpsys.cpp index 7a17d6b9c..0fc0c0ef6 100644 --- a/zencore/httpsys.cpp +++ b/zencore/httpsys.cpp @@ -621,7 +621,7 @@ HttpMessageResponseRequest::IssueRequest() ////////////////////////////////////////////////////////////////////////// -HttpSysServer::HttpSysServer(WinIoThreadPool& InThreadPool) : m_ThreadPool(InThreadPool) +HttpSysServer::HttpSysServer(int ThreadCount) : m_ThreadPool(ThreadCount) { ULONG Result = HttpInitialize(HTTPAPI_VERSION_2, HTTP_INITIALIZE_SERVER, nullptr); @@ -784,11 +784,6 @@ HttpSysServer::IssueNewRequestMaybe() } void -HttpSysServer::StopServer() -{ -} - -void HttpSysServer::AddEndpoint(const char* UrlPath, HttpService& Service) { if (UrlPath[0] == '/') @@ -1221,6 +1216,35 @@ InitialRequestHandler::HandleCompletion(ULONG IoResult, ULONG_PTR NumberOfBytesT return new HttpMessageResponseRequest(Transaction(), 500, ex.what()); } } + +////////////////////////////////////////////////////////////////////////// +// +// HttpServer interface implementation +// + +void +HttpSysServer::Initialize(int BasePort) +{ + using namespace std::literals; + + WideStringBuilder<64> BaseUri; + BaseUri << u8"http://*:"sv << int64_t(BasePort) << u8"/"sv; + + Initialize(BaseUri.c_str()); + StartServer(); +} + +void +HttpSysServer::RequestExit() +{ + m_ShutdownEvent.Set(); +} +void +HttpSysServer::AddEndpoint(HttpService& Service) +{ + AddEndpoint(Service.BaseUri(), Service); +} + #endif // ZEN_PLATFORM_WINDOWS } // namespace zen |