Skip to content

Commit

Permalink
Update code Updated for ESPAsyncWebServer benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieucarbou committed Oct 15, 2024
1 parent 813caee commit c5bf9e9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion benchmark/espasyncwebserver/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ const char* htmlContent = R"(
</html>
)";

const size_t htmlContentLen = strlen(htmlContent);

bool connectToWifi()
{
Serial.println();
Expand Down Expand Up @@ -241,7 +243,11 @@ void setup()
}

// api - parameters passed in via query eg. /api/endpoint?foo=bar
server.on("/", HTTP_GET, [](AsyncWebServerRequest* request) { request->send(200, "text/html", htmlContent); });
server.on("/", HTTP_GET, [](AsyncWebServerRequest* request) {
// ESPAsyncWebServer, sending a char* does a buffer copy, unlike Psychic.
// Sending flash data is done with the uint8_t* overload.
request->send(200, "text/html", (uint8_t*)htmlContent, htmlContentLen);
});

// api - parameters passed in via query eg. /api/endpoint?foo=bar
server.on("/api", HTTP_GET, [](AsyncWebServerRequest* request) {
Expand Down

0 comments on commit c5bf9e9

Please sign in to comment.