From 565f08ec3327c6cdad2eeb2fac1f45a1a24b95cf Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Thu, 9 Sep 2021 13:58:37 +0200 Subject: Made HttpServer an abstract interface, and moved remaining implementation specifics for http.sys into the dedicated cpp/h source files --- zencore/httpsys.cpp | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) (limited to 'zencore/httpsys.cpp') 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); @@ -783,11 +783,6 @@ HttpSysServer::IssueNewRequestMaybe() Request.release(); } -void -HttpSysServer::StopServer() -{ -} - void HttpSysServer::AddEndpoint(const char* UrlPath, HttpService& Service) { @@ -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 -- cgit v1.2.3