diff options
Diffstat (limited to 'src/main.zig')
-rw-r--r-- | src/main.zig | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/main.zig b/src/main.zig index 1f4d8f9..70869b2 100644 --- a/src/main.zig +++ b/src/main.zig @@ -10,7 +10,8 @@ const Context = struct { }; const Handler = struct { pub fn handle(_: Handler, res: *std.http.Server.Response, _: Context) !void { - const p = try zws.Path.parse(res.request.target); + var p = try zws.Path.parse(res.allocator, res.request.target); + defer p.deinit(); const path = try std.fs.path.join(res.allocator, &[_][]const u8{ ".", p.path }); defer res.allocator.free(path); if (std.fs.cwd().openFile(path, .{})) |file| { @@ -43,7 +44,7 @@ const Handler = struct { while (true) { const read = try file.read(&buf); if (read == 0) break; - _ = try res.write(buf[0..read]); + _ = try res.writeAll(buf[0..read]); } } |