Skip to content

Commit

Permalink
allow stopping server
Browse files Browse the repository at this point in the history
  • Loading branch information
andiwand committed Jan 9, 2025
1 parent 9414306 commit 83eea1d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
8 changes: 1 addition & 7 deletions src/odr/html_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,7 @@ const HtmlResourceLocator &HtmlDocumentService::resource_locator() const {
HtmlResources HtmlDocumentService::write_document(std::ostream &os) const {
internal::html::HtmlWriter out(os, config());

auto internal_resources = m_impl->write_document(out);

HtmlResources resources;
for (const auto &[resource, location] : internal_resources) {
resources.emplace_back(HtmlResource(resource), location);
}
return resources;
return m_impl->write_document(out);
}

const std::shared_ptr<internal::abstract::HtmlDocumentService> &
Expand Down
4 changes: 4 additions & 0 deletions src/odr/http_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ class HttpServer::Impl {
m_server.listen(host, static_cast<int>(port));
}

void stop() { m_server.stop(); }

private:
[[nodiscard]] static std::string get_id() {
std::mt19937 rng(std::random_device{}());
Expand Down Expand Up @@ -192,4 +194,6 @@ void HttpServer::listen(const std::string &host, std::uint32_t port) {
m_impl->listen(host, port);
}

void HttpServer::stop() { m_impl->stop(); }

} // namespace odr
2 changes: 2 additions & 0 deletions src/odr/http_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class HttpServer {

void listen(const std::string &host, std::uint32_t port);

void stop();

private:
class Impl;

Expand Down

0 comments on commit 83eea1d

Please sign in to comment.