1
0
mirror of https://github.com/esphome/esphome.git synced 2025-11-19 16:25:50 +00:00

Compare commits

..

1 Commits

Author SHA1 Message Date
J. Nick Koston
5c2cf9f37c [web_server_base] Replace shared_ptr with unique_ptr for AsyncWebServer 2025-11-18 16:10:07 -06:00
8 changed files with 31 additions and 17 deletions

View File

@@ -21,7 +21,8 @@
#include "esphome/components/dashboard_import/dashboard_import.h"
#endif
namespace esphome::mdns {
namespace esphome {
namespace mdns {
static const char *const TAG = "mdns";
@@ -188,5 +189,6 @@ void MDNSComponent::dump_config() {
#endif
}
} // namespace esphome::mdns
} // namespace mdns
} // namespace esphome
#endif

View File

@@ -6,7 +6,8 @@
#include "esphome/core/component.h"
#include "esphome/core/helpers.h"
namespace esphome::mdns {
namespace esphome {
namespace mdns {
// Helper struct that identifies strings that may be stored in flash storage (similar to LogString)
struct MDNSString;
@@ -78,5 +79,6 @@ class MDNSComponent : public Component {
void compile_records_(StaticVector<MDNSService, MDNS_SERVICE_COUNT> &services);
};
} // namespace esphome::mdns
} // namespace mdns
} // namespace esphome
#endif

View File

@@ -7,7 +7,8 @@
#include "esphome/core/log.h"
#include "mdns_component.h"
namespace esphome::mdns {
namespace esphome {
namespace mdns {
static const char *const TAG = "mdns";
@@ -55,6 +56,7 @@ void MDNSComponent::on_shutdown() {
delay(40); // Allow the mdns packets announcing service removal to be sent
}
} // namespace esphome::mdns
} // namespace mdns
} // namespace esphome
#endif // USE_ESP32

View File

@@ -9,7 +9,8 @@
#include "esphome/core/log.h"
#include "mdns_component.h"
namespace esphome::mdns {
namespace esphome {
namespace mdns {
void MDNSComponent::setup() {
#ifdef USE_MDNS_STORE_SERVICES
@@ -51,6 +52,7 @@ void MDNSComponent::on_shutdown() {
delay(10);
}
} // namespace esphome::mdns
} // namespace mdns
} // namespace esphome
#endif

View File

@@ -6,7 +6,8 @@
#include "esphome/core/log.h"
#include "mdns_component.h"
namespace esphome::mdns {
namespace esphome {
namespace mdns {
void MDNSComponent::setup() {
// Host platform doesn't have actual mDNS implementation
@@ -14,6 +15,7 @@ void MDNSComponent::setup() {
void MDNSComponent::on_shutdown() {}
} // namespace esphome::mdns
} // namespace mdns
} // namespace esphome
#endif

View File

@@ -9,7 +9,8 @@
#include <mDNS.h>
namespace esphome::mdns {
namespace esphome {
namespace mdns {
void MDNSComponent::setup() {
#ifdef USE_MDNS_STORE_SERVICES
@@ -45,6 +46,7 @@ void MDNSComponent::setup() {
void MDNSComponent::on_shutdown() {}
} // namespace esphome::mdns
} // namespace mdns
} // namespace esphome
#endif

View File

@@ -9,7 +9,8 @@
#include <ESP8266mDNS.h>
namespace esphome::mdns {
namespace esphome {
namespace mdns {
void MDNSComponent::setup() {
#ifdef USE_MDNS_STORE_SERVICES
@@ -50,6 +51,7 @@ void MDNSComponent::on_shutdown() {
delay(40);
}
} // namespace esphome::mdns
} // namespace mdns
} // namespace esphome
#endif

View File

@@ -111,7 +111,7 @@ class WebServerBase : public Component {
this->initialized_++;
return;
}
this->server_ = std::make_shared<AsyncWebServer>(this->port_);
this->server_ = std::make_unique<AsyncWebServer>(this->port_);
// All content is controlled and created by user - so allowing all origins is fine here.
DefaultHeaders::Instance().addHeader("Access-Control-Allow-Origin", "*");
this->server_->begin();
@@ -127,7 +127,7 @@ class WebServerBase : public Component {
this->server_ = nullptr;
}
}
std::shared_ptr<AsyncWebServer> get_server() const { return server_; }
AsyncWebServer *get_server() const { return this->server_.get(); }
float get_setup_priority() const override;
#ifdef USE_WEBSERVER_AUTH
@@ -143,7 +143,7 @@ class WebServerBase : public Component {
protected:
int initialized_{0};
uint16_t port_{80};
std::shared_ptr<AsyncWebServer> server_{nullptr};
std::unique_ptr<AsyncWebServer> server_{nullptr};
std::vector<AsyncWebHandler *> handlers_;
#ifdef USE_WEBSERVER_AUTH
internal::Credentials credentials_;