Skip to content

Commit

Permalink
- Use constructor overloading for new URI parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushsharma82 committed Dec 3, 2023
1 parent 09f4d29 commit 97abdaf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 8 additions & 3 deletions src/ESPDash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,22 @@ struct ChartNames chartTags[] = {


/*
Constructor
Constructors
*/
ESPDash::ESPDash(AsyncWebServer* server, bool enable_default_stats, const char *location) {
ESPDash::ESPDash(AsyncWebServer* server, bool enable_default_stats) {
// Call other constructor with default uri
ESPDash(server, "/", enable_default_stats);
}

ESPDash::ESPDash(AsyncWebServer* server, const char* uri, bool enable_default_stats) {
_server = server;
default_stats_enabled = enable_default_stats;

// Initialize AsyncWebSocket
_ws = new AsyncWebSocket("/dashws");

// Attach AsyncWebServer Routes
_server->on(location, HTTP_GET, [this](AsyncWebServerRequest *request){
_server->on(uri, HTTP_GET, [this](AsyncWebServerRequest *request){
if(basic_auth){
if(!request->authenticate(username.c_str(), password.c_str()))
return request->requestAuthentication();
Expand Down
4 changes: 2 additions & 2 deletions src/ESPDash.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ class ESPDash{
void refreshLayout();

public:

ESPDash(AsyncWebServer* server, bool enable_default_stats = true, const char *location = "/");
ESPDash(AsyncWebServer* server, bool enable_default_stats);
ESPDash(AsyncWebServer* server, const char* uri, bool enable_default_stats);

// Set Authentication
void setAuthentication(const char* user, const char* pass);
Expand Down

0 comments on commit 97abdaf

Please sign in to comment.