Use body_tag_from_query_param

This commit is contained in:
jaina heartles 2022-12-16 02:05:20 -08:00
parent 57f2bd821e
commit 6dc8447343
2 changed files with 9 additions and 13 deletions

View file

@ -282,20 +282,17 @@ const drive = struct {
mkdir,
};
pub const Body = struct {
action: Action,
data: union(Action) {
mkdir: struct {
name: []const u8,
},
pub const body_tag_from_query_param = "action";
pub const Body = union(Action) {
mkdir: struct {
name: []const u8,
},
};
pub fn handler(req: anytype, res: anytype, srv: anytype) !void {
if (req.body.action != req.body.data) return error.BadRequest;
switch (req.body.data) {
.mkdir => |data| {
_ = try srv.driveMkdir(req.args.path, data.name);
switch (req.body) {
.mkdir => |body| {
_ = try srv.driveMkdir(req.args.path, body.name);
// TODO
try servePage(req, res, srv);

View file

@ -29,12 +29,11 @@
<a class="button popup-close" href="#">
<i class="fa-solid fa-xmark"></i>
</a>
<form class="popup-dialog" method="post" enctype="multipart/form-data">
<form class="popup-dialog" action="?action=mkdir" method="post" enctype="multipart/form-data">
<label>
<div>Create Directory</div>
<input type="text" name="mkcol.name" /> <!-- TODO: Rename this form param -->
<input type="text" name="name" />
</label>
<input type="hidden" name="action" value="mkcol" />
<button type="submit">Create</button>
</form>
</div>