const std = @import("std"); const zap = @import("zap"); var gpa = std.heap.GeneralPurposeAllocator(.{ .thread_safe = true, }){}; fn on_request_verbose(r: zap.Request) void { // use a local buffer for the parsed accept headers var accept_buffer: [1024]u8 = undefined; var fba = std.heap.FixedBufferAllocator.init(&accept_buffer); const accept_allocator = fba.allocator(); const content_type: zap.ContentType = content_type: { var accept_list = r.parseAcceptHeaders(accept_allocator) catch break :content_type .HTML; defer accept_list.deinit(); for (accept_list.items) |accept| { break :content_type accept.toContentType() orelse continue; } break :content_type .HTML; }; r.setContentType(content_type) catch return; switch (content_type) { .TEXT => { r.sendBody("Hello from ZAP!!!") catch return; }, .HTML => { r.sendBody("