From 68355e97f78ef882be9b26dc39b94271462d275b Mon Sep 17 00:00:00 2001 From: --global Date: Wed, 15 Jul 2026 23:12:15 +0300 Subject: [PATCH] feat: add host parameter to http::server::listen Allow callers to choose the bind address instead of always using 0.0.0.0. The single-argument listen() overload keeps the previous default. Co-authored-by: Cursor --- net/net-http_server.c++m | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/net/net-http_server.c++m b/net/net-http_server.c++m index 5007715..69e878c 100644 --- a/net/net-http_server.c++m +++ b/net/net-http_server.c++m @@ -199,15 +199,21 @@ public: } void listen(std::string_view service_or_port = "http") + { + listen("0.0.0.0"sv, service_or_port); + } + + void listen(std::string_view host, std::string_view service_or_port) { using namespace std::string_view_literals; m_stop.store(false); - net::slog << net::notice("HTTP_SERVER_START") << "starting up at " << service_or_port + net::slog << net::notice("HTTP_SERVER_START") << "starting up at " << host << ":" << service_or_port + << std::pair{"addr"sv, host} << std::pair{"port"sv, service_or_port} << net::flush; try { - auto endpoint = net::acceptor{"0.0.0.0", service_or_port}; + auto endpoint = net::acceptor{host, service_or_port}; auto check_timeout = m_timeout.count() ? m_timeout : std::chrono::seconds{1}; endpoint.timeout(std::chrono::milliseconds{check_timeout.count() * 1000}); net::slog << net::notice("HTTP_SERVER_READY") << "started up at " << endpoint.host() << ":" << endpoint.service_or_port()