SensESP 3.0.1
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
static_file_handler.cpp
Go to the documentation of this file.
2
4
5namespace sensesp {
6
7void add_static_file_handlers(std::shared_ptr<HTTPServer> server) {
8 for (int i = 0; kFrontendFiles[i].url != nullptr; i++) {
9 const StaticFileData& data = kFrontendFiles[i];
10 auto handler = std::make_shared<HTTPRequestHandler>(
11 1 << HTTP_GET, kFrontendFiles[i].url, [data](httpd_req_t* req) {
12 httpd_resp_set_type(req, data.content_type);
13 if (data.content_encoding != nullptr) {
14 httpd_resp_set_hdr(req, kContentEncoding, data.content_encoding);
15 }
16 httpd_resp_send(req, data.content, data.content_length);
17 return ESP_OK;
18 });
19 server->add_handler(handler);
20 }
21}
22
23} // namespace sensesp
const char kContentEncoding[]
void add_static_file_handlers(std::shared_ptr< HTTPServer > server)
Provide handlers for static web content.
const StaticFileData kFrontendFiles[]
const unsigned int content_length