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);
},
else => {
std.log.debug("{}", .{content_type});
return error.UnsupportedMediaType;
.url_encoded => return query_utils.parseQuery(alloc, T, buf) catch |err| switch (err) {
error.NoQuery => error.NoBody,
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});
}
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 {