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.
1
#include "
static_file_handler.h
"
2
3
#include "
autogen/frontend_files.h
"
4
5
namespace
sensesp
{
6
7
void
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
frontend_files.h
sensesp
Definition
sensesp.cpp:7
sensesp::kContentEncoding
const char kContentEncoding[]
Definition
static_file_data.h:7
sensesp::add_static_file_handlers
void add_static_file_handlers(std::shared_ptr< HTTPServer > server)
Provide handlers for static web content.
Definition
static_file_handler.cpp:7
sensesp::kFrontendFiles
const StaticFileData kFrontendFiles[]
Definition
frontend_files.h:8
static_file_handler.h
sensesp::StaticFileData
Definition
static_file_data.h:9
sensesp::StaticFileData::content_encoding
const char * content_encoding
Definition
static_file_data.h:14
sensesp::StaticFileData::url
const char * url
Definition
static_file_data.h:10
sensesp::StaticFileData::content_type
const char * content_type
Definition
static_file_data.h:13
sensesp::StaticFileData::content
const char * content
Definition
static_file_data.h:11
sensesp::StaticFileData::content_length
const unsigned int content_length
Definition
static_file_data.h:12
src
sensesp
net
web
static_file_handler.cpp
Generated by
1.12.0