mirror of
https://github.com/zigzap/zap.git
synced 2025-10-20 15:14:08 +00:00
Added setContentTypeFromPath()
This commit is contained in:
parent
734b17377f
commit
0b368f14dd
2 changed files with 9 additions and 0 deletions
|
@ -13,6 +13,7 @@ fn on_request(r: zap.SimpleRequest) void {
|
|||
std.debug.print(">> BODY: {s}\n", .{the_body});
|
||||
}
|
||||
|
||||
r.setContentTypeFromPath();
|
||||
_ = r.sendBody(
|
||||
\\ <html><body>
|
||||
\\ <h1>Hello from ZAP!!!</h1>
|
||||
|
|
|
@ -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),
|
||||
|
|
Loading…
Add table
Reference in a new issue