This commit is contained in:
jpirnay
2026-03-26 11:06:34 +01:00
parent 1af3f81336
commit 33347d5b96
+20 -5
View File
@@ -978,16 +978,31 @@ void CrossPointWebServer::handleMove() const {
} }
void CrossPointWebServer::handleDelete() const { void CrossPointWebServer::handleDelete() const {
// Check if 'paths' argument is provided // To ensure backwards compatibility, plain `path` is mapped
if (!server->hasArg("paths")) { // to a single element JSON array.
server->send(400, "text/plain", "Missing paths"); bool hasPathArg = server->hasArg("path");
bool hasPathsArg = server->hasArg("paths");
// Check 'paths' or `path` argument is provided
if (!(hasPathArg || hasPathsArg)) {
server->send(400, "text/plain", "Missing `path` or `paths` argument");
return;
}
if (hasPathArg && hasPathsArg) {
server->send(400, "text/plain", "Provide either 'path' or 'paths', not both");
return; return;
} }
// Parse paths // Parse paths
String pathsArg = server->arg("paths"); String pathsArg;
JsonDocument doc; JsonDocument doc;
DeserializationError error = deserializeJson(doc, pathsArg); DeserializationError error = DeserializationError(DeserializationError::Code::Ok);
if (hasPathsArg) {
pathsArg = server->arg("paths");
error = deserializeJson(doc, pathsArg);
} else {
pathsArg = server->arg("path");
doc.add(pathsArg);
}
if (error) { if (error) {
server->send(400, "text/plain", "Invalid paths format"); server->send(400, "text/plain", "Invalid paths format");
return; return;