Skip to content

Conversation

@kaigoh
Copy link
Contributor

@kaigoh kaigoh commented Jul 25, 2024

Add some pointers to the default document, so it can be referred to elsewhere by name ("dataDefaultDocument", "lengthDefaultDocument", "etagDefaultDocument").

That way, I can do this to keep SvelteKit routing happy:

server.onNotFound([](AsyncWebServerRequest *request)
{
if (request->hasHeader("If-None-Match") && request->getHeader("If-None-Match")->value() == String(etagDefaultDocument))
{
request->send(304);
return;
}
AsyncWebServerResponse *response = request->beginResponse_P(200, "text/html", dataDefaultDocument, lengthDefaultDocument);
response->addHeader("Content-Encoding", "gzip");
response->addHeader("ETag", etagDefaultDocument);
request->send(response); });

You could also rewrite the template that generates the C++ to just give the default document variables a different name rather than adding pointers, but I figured this was just quick and dirty and achieves the same goal.

Add some pointers to the default document, so it can be referred to elsewhere by name ("dataDefaultDocument", "lengthDefaultDocument", "etagDefaultDocument"). That way, I can do this to keep SvelteKit routing happy: server.onNotFound([](AsyncWebServerRequest *request) { if (request->hasHeader("If-None-Match") && request->getHeader("If-None-Match")->value() == String(etagDefaultDocument)) { request->send(304); return; } AsyncWebServerResponse *response = request->beginResponse_P(200, "text/html", dataDefaultDocument, lengthDefaultDocument); response->addHeader("Content-Encoding", "gzip"); response->addHeader("ETag", etagDefaultDocument); request->send(response); }); You could also rewrite the template that generates the C++ to just give the default document variables a different name rather than adding pointers, but I figured this was just quick and dirty and achieves the same goal.
@kaigoh
Copy link
Contributor Author

kaigoh commented Jul 25, 2024

You can't obtain pointers to data stored in PROGMEM, so I'll need to go back and just edit the template instead. :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant