diff options
author | Martin Ashby <martin@ashbysoft.com> | 2024-02-01 14:12:03 +0000 |
---|---|---|
committer | Martin Ashby <martin@ashbysoft.com> | 2024-02-01 14:12:03 +0000 |
commit | c0b0b259a572bcc65dd2e6d55a126ead9c2ae6ff (patch) | |
tree | fa12113b6466c5dff14596a7b7bbdb34590ad6ff /src | |
parent | a782c7083056558ccfe41ca42857a4680d55a9d9 (diff) | |
download | zigwebserver-c0b0b259a572bcc65dd2e6d55a126ead9c2ae6ff.tar.gz zigwebserver-c0b0b259a572bcc65dd2e6d55a126ead9c2ae6ff.tar.bz2 zigwebserver-c0b0b259a572bcc65dd2e6d55a126ead9c2ae6ff.tar.xz zigwebserver-c0b0b259a572bcc65dd2e6d55a126ead9c2ae6ff.zip |
Update for zig master
Diffstat (limited to 'src')
-rw-r--r-- | src/main.zig | 4 | ||||
-rw-r--r-- | src/zigwebserver.zig | 10 |
2 files changed, 7 insertions, 7 deletions
diff --git a/src/main.zig b/src/main.zig index 70869b2..11f6d0d 100644 --- a/src/main.zig +++ b/src/main.zig @@ -39,7 +39,7 @@ const Handler = struct { fn serve_file(res: *std.http.Server.Response, file: std.fs.File, md: std.fs.File.Metadata) !void { res.transfer_encoding = .{ .content_length = md.size() }; - try res.do(); + try res.send(); var buf = [_]u8{0} ** 1024; while (true) { const read = try file.read(&buf); @@ -51,7 +51,7 @@ const Handler = struct { fn serve_error(res: *std.http.Server.Response, status: std.http.Status) !void { res.status = status; res.transfer_encoding = .chunked; - try res.do(); + try res.send(); const phrase = status.phrase() orelse "error!"; try std.fmt.format(res.writer(), \\ <!doctype html><html><body>{s}</body></html> diff --git a/src/zigwebserver.zig b/src/zigwebserver.zig index acf65fb..64bd649 100644 --- a/src/zigwebserver.zig +++ b/src/zigwebserver.zig @@ -19,7 +19,7 @@ pub fn Server(comptime Context: type, comptime Handler: type) type { try tp.init(.{ .allocator = self.allocator, .n_jobs = self.n_threads }); defer tp.deinit(); - var svr_internal = std.http.Server.init(self.allocator, .{ .reuse_address = true }); + var svr_internal = std.http.Server.init(.{ .reuse_address = true }); defer svr_internal.deinit(); try svr_internal.listen(self.address); std.log.info("server listening on {}", .{self.address}); @@ -57,7 +57,7 @@ pub fn Server(comptime Context: type, comptime Handler: type) type { res.status = status; res.transfer_encoding = .{ .content_length = content.len }; try res.headers.append("content-type", "text/html"); - try res.do(); + try res.send(); try res.writer().writeAll(content); try res.finish(); } @@ -185,7 +185,7 @@ const RouterTest = struct { .method = .GET, .target = target, }; - var res = TestResponse{ + const res = TestResponse{ .request = req, }; const router = TestRouter{ @@ -225,8 +225,8 @@ const RouterTest = struct { var it = pexp.keyIterator(); var kexp = it.next(); while (kexp != null) : (kexp = it.next()) { - var vexp = pexp.get(kexp.?.*).?; - var maybe_vact = pact.get(kexp.?.*); + const vexp = pexp.get(kexp.?.*).?; + const maybe_vact = pact.get(kexp.?.*); if (maybe_vact) |vact| { std.debug.print("{s} {s}", .{ vexp, vact }); try std.testing.expectEqual(vexp, vact); |