diff --git a/include/crow/app.h b/include/crow/app.h index 062f884a5..d349d9528 100644 --- a/include/crow/app.h +++ b/include/crow/app.h @@ -323,6 +323,16 @@ namespace crow } } + /// \brief Set status variable to note that the address that Crow will handle requests on is bound + void address_is_bound() { + is_bound_ = true; + } + + /// \brief Get whether address that Crow will handle requests on is bound + bool is_bound() const { + return is_bound_; + } + /// \brief Set the connection timeout in seconds (default is 5) self_t& timeout(std::uint8_t timeout) { @@ -803,6 +813,7 @@ namespace crow std::uint8_t timeout_{5}; uint16_t port_ = 80; unsigned int concurrency_ = 2; + std::atomic_bool is_bound_ = false; uint64_t max_payload_{UINT64_MAX}; std::string server_name_ = std::string("Crow/") + VERSION; std::string bindaddr_ = "0.0.0.0"; diff --git a/include/crow/http_server.h b/include/crow/http_server.h index dd3e08117..4e6c32475 100644 --- a/include/crow/http_server.h +++ b/include/crow/http_server.h @@ -200,6 +200,7 @@ namespace crow // NOTE: Already documented in "crow/app.h" }); } handler_->port(acceptor_.port()); + handler_->address_is_bound(); CROW_LOG_INFO << server_name_ << " server is running at " << acceptor_.url_display(handler_->ssl_used()) << " using " << concurrency_ << " threads";