diff --git a/src/main/controllers/web.zig b/src/main/controllers/web.zig index d1feafd..5ec6d55 100644 --- a/src/main/controllers/web.zig +++ b/src/main/controllers/web.zig @@ -280,6 +280,7 @@ const drive = struct { const Action = enum { mkdir, + delete, }; pub const body_tag_from_query_param = "action"; @@ -287,6 +288,7 @@ const drive = struct { mkdir: struct { name: []const u8, }, + delete: struct {}, }; pub fn handler(req: anytype, res: anytype, srv: anytype) !void { @@ -297,6 +299,19 @@ const drive = struct { try servePage(req, res, srv); }, + .delete => { + const trimmed_path = std.mem.trim(u8, req.args.path, "/"); + _ = try srv.driveDelete(trimmed_path); + + const dir = trimmed_path[0 .. std.mem.lastIndexOfScalar(u8, trimmed_path, '/') orelse trimmed_path.len]; + const url = try std.fmt.allocPrint(srv.allocator, "{s}/drive/{s}", .{ + req.mount_path, + dir, + }); + defer srv.allocator.free(url); + try res.headers.put("Location", url); + return res.status(.see_other); + }, } } }; diff --git a/src/main/controllers/web/drive/directory.tmpl.html b/src/main/controllers/web/drive/directory.tmpl.html index 277174d..39f4b2d 100644 --- a/src/main/controllers/web/drive/directory.tmpl.html +++ b/src/main/controllers/web/drive/directory.tmpl.html @@ -48,6 +48,25 @@ {$dir.name.?} +