forked from me-no-dev/ESPAsyncWebServer
-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Description
How to use properly the cookie auth instead of request->authenticate ?
Do we need to use it for webpages and ws also, or only in server.on- (headers request) enough?
WServer.on("/syst", HTTP_GET, [](AsyncWebServerRequest *request) {
sendHTMLResponse(request, system_html, sizeof(system_html), (TEXT_HTML), P_SYSTEM);
});
void sendHTMLResponse(AsyncWebServerRequest *request, const uint8_t *htmlContent, size_t htmlSize, const char *contentType, html_pages_t setpage)
{
if (dev_auth && !request->authenticate(dev_user, dev_pass))
return request->requestAuthentication();
#if defined(ESP32)
AsyncWebServerResponse *response = request->beginResponse(200, contentType, htmlContent, htmlSize);
#elif defined(ESP8266)
AsyncWebServerResponse *response = request->beginResponse_P(200, contentType, htmlContent, htmlSize);
#endif
response->addHeader((CONTENT_ENCODING), (GZIP));
request->send(response);
current_html_page = setpage;
}
Metadata
Metadata
Assignees
Labels
No labels