srctree

Gregory Mullen parent 42d48d8f b302e98e
add another content type decl

inlinesplit
src/content-type.zig added: 8, removed: 10, total 0
@@ -5,6 +5,10 @@ const ContentType = @This();
 
pub const @"text/plain": ContentType = .{ .base = .{ .text = .plain } };
pub const @"text/html": ContentType = .{ .base = .{ .text = .html }, .parameter = .@"utf-8" };
pub const @"application/json": ContentType = .{ .base = .{ .application = .json }, .parameter = .@"utf-8" };
 
pub const html: ContentType = .@"text/html";
pub const json: ContentType = .@"application/json";
 
pub const default: ContentType = .{
.base = .{ .text = .html },
 
src/frame.zig added: 8, removed: 10, total 0
@@ -115,10 +115,7 @@ pub fn sendJSON(fr: *Frame, comptime code: std.http.Status, json: anytype) Netwo
}
 
fr.status = code;
fr.content_type = .{
.base = .{ .application = .json },
.parameter = .@"utf-8",
};
fr.content_type = .json;
 
fr.sendHeaders() catch |err| switch (err) {
error.BrokenPipe => |e| return e,
@@ -143,10 +140,7 @@ pub fn sendJSON(fr: *Frame, comptime code: std.http.Status, json: anytype) Netwo
 
pub fn sendHTML(frame: *Frame, comptime code: std.http.Status, html: []const u8) NetworkError!void {
frame.status = code;
frame.content_type = .{
.base = .{ .text = .html },
.parameter = .@"utf-8",
};
frame.content_type = .html;
 
frame.sendHeaders() catch |err| switch (err) {
error.BrokenPipe => |e| return e,