32 auto info_handler = std::make_shared<HTTPRequestHandler>(
33 1 << HTTP_GET,
"/api/info", [](httpd_req_t* req) {
36 JsonDocument json_doc;
37 JsonArray info_items = json_doc.to<JsonArray>();
39 for (
auto info_item = status_page_items->begin();
40 info_item != status_page_items->end(); ++info_item) {
41 info_items.add(info_item->second->as_json());
45 serializeJson(json_doc, response);
46 httpd_resp_set_type(req,
"application/json");
47 httpd_resp_sendstr(req, response.c_str());
50 server->add_handler(info_handler);
54 std::vector<RouteDefinition> routes;
59 routes.push_back(
RouteDefinition(
"Signal K",
"/signalk",
"SignalKPage"));
61 RouteDefinition(
"Configuration",
"/configuration",
"ConfigurationPage"));
64 JsonDocument json_doc;
65 JsonArray routes_json = json_doc.to<JsonArray>();
67 int sz = routes.size();
69 for (
auto it = routes.begin(); it != routes.end(); ++it) {
70 routes_json.add(it->as_json());
75 serializeJson(routes_json, response);
77 auto routes_handler = std::make_shared<HTTPRequestHandler>(
78 1 << HTTP_GET,
"/api/routes", [response](httpd_req_t* req) {
79 httpd_resp_set_type(req,
"application/json");
80 httpd_resp_sendstr(req, response.c_str());
83 server->add_handler(routes_handler);
94 if (root_page ==
nullptr) {
95 ESP_LOGE(__FILENAME__,
"Root page not found in kWebUIFiles");
101 for (
auto it = routes.begin(); it != routes.end(); ++it) {
102 String path = it->get_path();
103 auto route_handler = std::make_shared<HTTPRequestHandler>(
104 1 << HTTP_GET, path.c_str(), [root_page](httpd_req_t* req) {
105 httpd_resp_set_type(req, root_page->content_type);
106 if (root_page->content_encoding != nullptr) {
107 httpd_resp_set_hdr(req, kContentEncoding,
108 root_page->content_encoding);
113 server->add_handler(route_handler);
static const std::map< String, StatusPageItemBase * > * get_status_page_items()