Skip to content

Update cppCode.ts #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Update cppCode.ts #14

wants to merge 1 commit into from

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant