diff --git a/examples/hello2/hello2.zig b/examples/hello2/hello2.zig
index b4e674f..372046d 100644
--- a/examples/hello2/hello2.zig
+++ b/examples/hello2/hello2.zig
@@ -13,6 +13,7 @@ fn on_request(r: zap.SimpleRequest) void {
std.debug.print(">> BODY: {s}\n", .{the_body});
}
+ r.setContentTypeFromPath();
_ = r.sendBody(
\\
\\ Hello from ZAP!!!
diff --git a/src/zap.zig b/src/zap.zig
index 5c0ab95..1d6f81b 100644
--- a/src/zap.zig
+++ b/src/zap.zig
@@ -83,6 +83,14 @@ pub const SimpleRequest = struct {
});
}
+ pub fn setContentTypeFromPath(self: *const Self) void {
+ _ = C.fiobj_hash_set(
+ self.h.*.private_data.out_headers,
+ C.HTTP_HEADER_CONTENT_TYPE,
+ C.http_mimetype_find2(self.h.*.path),
+ );
+ }
+
pub fn setHeader(self: *const Self, name: []const u8, value: []const u8) void {
const hname: C.fio_str_info_s = .{
.data = toCharPtr(name),