From 5e4b0b5a40a9beb75ab8b6e0a1441620625d60f0 Mon Sep 17 00:00:00 2001 From: --global Date: Thu, 16 Jul 2026 08:04:21 +0300 Subject: [PATCH] feat: add listen bound callback and 503 status constant http::server::listen(host, port, on_bound) invokes on_bound after the acceptor binds. Adds status_service_unavailable for readiness probes. 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 69e878c..7b8cb22 100644 --- a/net/net-http_server.c++m +++ b/net/net-http_server.c++m @@ -39,6 +39,7 @@ const auto status_payload_too_large = "413 Payload Too Large"s; const auto status_unprocessable_entity = "422 Unprocessable Entity"s; const auto status_too_many_requests = "429 Too Many Requests"s; const auto status_internal_server_error = "500 Internal Server Error"s; +const auto status_service_unavailable = "503 Service Unavailable"s; using status = std::string; using content = std::string; @@ -200,10 +201,13 @@ public: void listen(std::string_view service_or_port = "http") { - listen("0.0.0.0"sv, service_or_port); + listen("0.0.0.0"sv, service_or_port, nullptr); } - void listen(std::string_view host, std::string_view service_or_port) + void listen( + std::string_view host, + std::string_view service_or_port, + std::function on_bound = nullptr) { using namespace std::string_view_literals; m_stop.store(false); @@ -220,6 +224,8 @@ public: << std::pair{"addr", endpoint.host()} << std::pair{"port", endpoint.service_or_port()} << net::flush; + if(on_bound) + on_bound(); while(!m_stop.load()) {