mirror of
https://github.com/Laxilef/OTGateway.git
synced 2026-12-05 20:53:07 +05:00
refactor: pass JSON response roots directly to toJson
This commit is contained in:
1 parent
6b2db61d8f
commit
2ad969bcab
1 file changed
+7
-14
+7
-14
@@ -742,8 +742,7 @@ static void restApi() {
|
|||||||
|
|
||||||
// Prepare response
|
// Prepare response
|
||||||
auto *response = new AsyncJsonResponse();
|
auto *response = new AsyncJsonResponse();
|
||||||
auto& doc = response->getRoot();
|
toJson(*sensorId, *sensor, response->getRoot());
|
||||||
toJson(*sensorId, *sensor, doc);
|
|
||||||
|
|
||||||
// Send response
|
// Send response
|
||||||
response->setLength();
|
response->setLength();
|
||||||
@@ -823,9 +822,8 @@ static void restApi() {
|
|||||||
|
|
||||||
// Prepare response
|
// Prepare response
|
||||||
auto *response = new AsyncJsonResponse();
|
auto *response = new AsyncJsonResponse();
|
||||||
auto& responseDoc = response->getRoot();
|
|
||||||
if (const auto sensor = Sensors::getSettings(*sensorId)) {
|
if (const auto sensor = Sensors::getSettings(*sensorId)) {
|
||||||
toJson(*sensorId, *sensor, responseDoc);
|
toJson(*sensorId, *sensor, response->getRoot());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send response
|
// Send response
|
||||||
@@ -858,8 +856,7 @@ static void restApi() {
|
|||||||
|
|
||||||
// Prepare response
|
// Prepare response
|
||||||
auto *response = new AsyncJsonResponse();
|
auto *response = new AsyncJsonResponse();
|
||||||
auto& doc = response->getRoot();
|
toJson(sensor->settings, sensor->result, response->getRoot());
|
||||||
toJson(sensor->settings, sensor->result, doc);
|
|
||||||
|
|
||||||
// Send response
|
// Send response
|
||||||
response->setLength();
|
response->setLength();
|
||||||
@@ -912,8 +909,7 @@ static void restApi() {
|
|||||||
|
|
||||||
// Prepare response
|
// Prepare response
|
||||||
auto *response = new AsyncJsonResponse();
|
auto *response = new AsyncJsonResponse();
|
||||||
auto& responseDoc = response->getRoot();
|
toJson(sensor->settings, sensor->result, response->getRoot());
|
||||||
toJson(sensor->settings, sensor->result, responseDoc);
|
|
||||||
|
|
||||||
// Send response
|
// Send response
|
||||||
response->setLength();
|
response->setLength();
|
||||||
@@ -988,8 +984,7 @@ static void restApi() {
|
|||||||
|
|
||||||
// Prepare response
|
// Prepare response
|
||||||
auto *response = new AsyncJsonResponse();
|
auto *response = new AsyncJsonResponse();
|
||||||
auto& responseDoc = response->getRoot();
|
toJson(sensor->settings, sensor->result, response->getRoot());
|
||||||
toJson(sensor->settings, sensor->result, responseDoc);
|
|
||||||
|
|
||||||
// Send response
|
// Send response
|
||||||
response->setLength();
|
response->setLength();
|
||||||
@@ -1002,8 +997,7 @@ static void restApi() {
|
|||||||
webServer->on("/api/vars", HTTP_GET, [](AsyncWebServerRequest *request) {
|
webServer->on("/api/vars", HTTP_GET, [](AsyncWebServerRequest *request) {
|
||||||
// Prepare response
|
// Prepare response
|
||||||
auto *response = new AsyncJsonResponse();
|
auto *response = new AsyncJsonResponse();
|
||||||
auto& doc = response->getRoot();
|
toJson(vars, response->getRoot());
|
||||||
toJson(vars, doc);
|
|
||||||
|
|
||||||
// Send response
|
// Send response
|
||||||
response->setLength();
|
response->setLength();
|
||||||
@@ -1025,8 +1019,7 @@ static void restApi() {
|
|||||||
|
|
||||||
// Prepare response
|
// Prepare response
|
||||||
auto *response = new AsyncJsonResponse();
|
auto *response = new AsyncJsonResponse();
|
||||||
auto& responseDoc = response->getRoot();
|
toJson(vars, response->getRoot());
|
||||||
toJson(vars, responseDoc);
|
|
||||||
|
|
||||||
// Send response
|
// Send response
|
||||||
response->setLength();
|
response->setLength();
|
||||||
|
|||||||
Reference in new issue
Block a user