add allocator to handler, fix registry call

This commit is contained in:
Luna 2021-04-13 21:32:24 -03:00
parent fa4590171d
commit 4287ae9c2a

View file

@ -295,13 +295,14 @@ fn uploadFile(response: *http.Response, request: http.Request) !void {
var multipart = try Multipart.init(request.body, content_type.?, &boundary_buffer); var multipart = try Multipart.init(request.body, content_type.?, &boundary_buffer);
var hzzp_buffer: [1024]u8 = undefined; var hzzp_buffer: [1024]u8 = undefined;
while (try multipart.next(&hzzp_buffer)) |part| { while (try multipart.next(&hzzp_buffer, global_allocator.?)) |part| {
defer part.deinit();
std.log.info( std.log.info(
"got part from multipart request! name='{s}' filename='{s}' content_type='{s}' length={d}", "got part from multipart request! name='{s}' filename='{s}' content_type='{s}' length={d}",
.{ part.disposition.name, part.disposition.filename, part.content_type, part.body.len }, .{ part.disposition.name, part.disposition.filename, part.content_type, part.body.len },
); );
var extensions = registry.getExtensionsByType(part.content_type); var extensions = registry.?.getExtensionsByType(part.content_type);
if (extensions == null) return error.InvalidContentMimeType; if (extensions == null) return error.InvalidContentMimeType;
const extension = extensions.?.items[0]; const extension = extensions.?.items[0];