optimize endpoints, so re-use where possible

This commit is contained in:
proddy
2024-09-13 10:03:11 +02:00
parent 63a3152b91
commit 191edffe3c
23 changed files with 192 additions and 428 deletions

View File

@@ -29,9 +29,6 @@ WebCustomEntityService::WebCustomEntityService(AsyncWebServer * server, FS * fs,
securityManager,
AuthenticationPredicates::IS_AUTHENTICATED)
, _fsPersistence(WebCustomEntity::read, WebCustomEntity::update, this, fs, EMSESP_CUSTOMENTITY_FILE) {
server->on(EMSESP_GET_ENTITIES_PATH,
HTTP_GET,
securityManager->wrapRequest([this](AsyncWebServerRequest * request) { getEntities(request); }, AuthenticationPredicates::IS_ADMIN));
}
// load the settings when the service starts
@@ -711,17 +708,4 @@ void WebCustomEntityService::test() {
}
#endif
// return entities as a json object
void WebCustomEntityService::getEntities(AsyncWebServerRequest * request) {
auto * response = new AsyncJsonResponse(false);
JsonObject root = response->getRoot();
root["type"] = "entities";
System::extractSettings(EMSESP_CUSTOMENTITY_FILE, "Entities", root);
response->setLength();
request->send(response);
}
} // namespace emsesp