Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Co-authored-by: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: tomaszduda23 <tomaszduda23@gmail.com>
26 lines
728 B
C++
26 lines
728 B
C++
#include "web_server_base.h"
|
|
#if defined(USE_NETWORK) && !defined(USE_ZEPHYR)
|
|
|
|
namespace esphome::web_server_base {
|
|
|
|
WebServerBase *global_web_server_base = nullptr; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
|
|
|
|
void WebServerBase::add_handler(AsyncWebHandler *handler) {
|
|
#ifdef USE_WEBSERVER_AUTH
|
|
if (!credentials_.username.empty()) {
|
|
handler = new internal::AuthMiddlewareHandler(handler, &credentials_);
|
|
}
|
|
#endif
|
|
this->add_handler_without_auth(handler);
|
|
}
|
|
|
|
void WebServerBase::add_handler_without_auth(AsyncWebHandler *handler) {
|
|
this->handlers_.push_back(handler);
|
|
if (this->server_ != nullptr) {
|
|
this->server_->addHandler(handler);
|
|
}
|
|
}
|
|
|
|
} // namespace esphome::web_server_base
|
|
#endif
|