Allow passing params by application/x-www-form-urlencoded

This commit is contained in:
jaina heartles 2022-11-15 01:03:47 -08:00
parent a15baaf2e7
commit 861c31c3ad
2 changed files with 5 additions and 4 deletions

View file

@ -103,10 +103,11 @@ fn parseBody(comptime T: type, content_type: BaseContentType, reader: anytype, a
return try util.deepClone(alloc, body); return try util.deepClone(alloc, body);
}, },
else => { .url_encoded => return query_utils.parseQuery(alloc, T, buf) catch |err| switch (err) {
std.log.debug("{}", .{content_type}); error.NoQuery => error.NoBody,
return error.UnsupportedMediaType; else => err,
}, },
else => return error.UnsupportedMediaType,
} }
} }

View file

@ -85,7 +85,7 @@ pub fn parseQuery(alloc: std.mem.Allocator, comptime T: type, query: []const u8)
} else std.log.debug("unknown param {s}", .{pair.key}); } else std.log.debug("unknown param {s}", .{pair.key});
} }
return (try parse(alloc, T, "", "", fields)).?; return (try parse(alloc, T, "", "", fields)) orelse error.NoQuery;
} }
fn decodeString(alloc: std.mem.Allocator, val: []const u8) ![]const u8 { fn decodeString(alloc: std.mem.Allocator, val: []const u8) ![]const u8 {