rename parseBodyFromRequest to parseBodyFromReader

This commit is contained in:
jaina heartles 2022-12-16 02:01:26 -08:00
parent 471ca527bb
commit e2281f7c14

View file

@ -634,7 +634,7 @@ const BaseContentType = enum {
other,
};
fn parseBodyFromRequest(
pub fn parseBodyFromReader(
comptime T: type,
comptime options: ParseBodyOptions,
content_type: ?[]const u8,
@ -703,7 +703,7 @@ pub fn ParseBody(comptime Body: type, comptime options: ParseBodyOptions) type {
}
var stream = req.body orelse return error.NoBody;
const body = try parseBodyFromRequest(Body, options, content_type, stream.reader(), ctx.allocator);
const body = try parseBodyFromReader(Body, options, content_type, stream.reader(), ctx.allocator);
defer util.deepFree(ctx.allocator, body);
return next.handle(
@ -719,11 +719,11 @@ pub fn parseBody(comptime Body: type) ParseBody(Body) {
return .{};
}
test "parseBodyFromRequest" {
test "parseBodyFromReader" {
const testCase = struct {
fn case(content_type: []const u8, body: []const u8, expected: anytype) !void {
var stream = std.io.StreamSource{ .const_buffer = std.io.fixedBufferStream(body) };
const result = try parseBodyFromRequest(@TypeOf(expected), .{}, content_type, stream.reader(), std.testing.allocator);
const result = try parseBodyFromReader(@TypeOf(expected), .{}, content_type, stream.reader(), std.testing.allocator);
defer util.deepFree(std.testing.allocator, result);
try util.testing.expectDeepEqual(expected, result);