Zig provides reader and writer interface to read and write data. If you want to read from one source and write to another one, you need a buffer and pay attentions to details. If there is no need to modify the data, Zig provides a LinearFifo to facilitate this process. Just get the reader and writer, then pump the data. That's it.
Here is an example where reader is from file and writer is from http.zig response (httpz.Response):
fn file(_: *httpz.Request, res: *httpz.Response) !void {
const path = "assets/logo.png";
var file_in = try std.fs.cwd().openFile(path, .{});
defer file_in.close();
var fifo = std.fifo.LinearFifo(u8, std.fifo.LinearFifoBufferType{ .Static = 4096 }).init();
const reader = file_in.reader();
const writer = res.writer();
res.content_type = httpz.ContentType.forFile(path);
try fifo.pump(reader, writer);
}
In this way, you can serve file from disk to browser with https.zig.