handle options in delete
This commit is contained in:
parent
bf9988e652
commit
bb63a284c8
@ -73,7 +73,7 @@ void CrossPointWebServer::begin() {
|
||||
server->on("/mkdir", HTTP_POST, [this] { handleCreateFolder(); });
|
||||
|
||||
// Delete file/folder endpoint
|
||||
server->on("/delete", HTTP_POST, [this] { handleDelete(); });
|
||||
server->on("/delete", HTTP_ANY, [this] { handleDelete(); });
|
||||
|
||||
server->onNotFound([this] { handleNotFound(); });
|
||||
Serial.printf("[%lu] [WEB] [MEM] Free heap after route setup: %d bytes\n", millis(), ESP.getFreeHeap());
|
||||
@ -404,14 +404,13 @@ void CrossPointWebServer::handleUpload() const {
|
||||
}
|
||||
|
||||
void CrossPointWebServer::handleUploadPost() const {
|
||||
if (server->method() == HTTP_OPTIONS) {
|
||||
server->enableCORS(true);
|
||||
if (server->method() == HTTP_OPTIONS) {
|
||||
server->send(204, "text/plain", "");
|
||||
return;
|
||||
}
|
||||
|
||||
if (server->method() == HTTP_POST) {
|
||||
server->enableCORS(true);
|
||||
if (uploadSuccess) {
|
||||
server->send(200, "text/plain", "File uploaded successfully: " + uploadFileName);
|
||||
} else {
|
||||
@ -475,6 +474,14 @@ void CrossPointWebServer::handleCreateFolder() const {
|
||||
}
|
||||
|
||||
void CrossPointWebServer::handleDelete() const {
|
||||
server->enableCORS(true);
|
||||
if (server->method() == HTTP_OPTIONS) {
|
||||
server->send(204, "text/plain", "");
|
||||
return;
|
||||
}
|
||||
|
||||
if (server->method() == HTTP_POST) {
|
||||
|
||||
// Get path from form data
|
||||
if (!server->hasArg("path")) {
|
||||
server->send(400, "text/plain", "Missing path");
|
||||
@ -554,4 +561,9 @@ void CrossPointWebServer::handleDelete() const {
|
||||
Serial.printf("[%lu] [WEB] Failed to delete: %s\n", millis(), itemPath.c_str());
|
||||
server->send(500, "text/plain", "Failed to delete item");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
server->send(405, "text/plain", "Method Not Allowed");
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user