diff --git a/examples/http_params/http_params.zig b/examples/http_params/http_params.zig index 68e4040..2c4f123 100644 --- a/examples/http_params/http_params.zig +++ b/examples/http_params/http_params.zig @@ -11,11 +11,12 @@ fn makeRequest(a: std.mem.Allocator, url: []const u8) !void { var http_client: std.http.Client = .{ .allocator = a }; defer http_client.deinit(); - var req = try http_client.request(.GET, uri, h, .{}); + var req = try http_client.fetch(a, .{ + .location = .{ .uri = uri }, + .method = .GET, + .headers = h, + }); defer req.deinit(); - - try req.start(); - try req.wait(); } fn makeRequestThread(a: std.mem.Allocator, url: []const u8) !std.Thread { @@ -27,7 +28,7 @@ pub fn main() !void { var gpa = std.heap.GeneralPurposeAllocator(.{ .thread_safe = true, }){}; - var allocator = gpa.allocator(); + const allocator = gpa.allocator(); const Handler = struct { var alloc: std.mem.Allocator = undefined; @@ -44,7 +45,7 @@ pub fn main() !void { // check for query parameters r.parseQuery(); - var param_count = r.getParamCount(); + const param_count = r.getParamCount(); std.log.info("param_count: {}", .{param_count}); // iterate over all params as strings diff --git a/examples/websockets/websockets.zig b/examples/websockets/websockets.zig index fea0933..e347242 100644 --- a/examples/websockets/websockets.zig +++ b/examples/websockets/websockets.zig @@ -46,8 +46,8 @@ const ContextManager = struct { self.lock.lock(); defer self.lock.unlock(); - var ctx = try self.allocator.create(Context); - var userName = try std.fmt.allocPrint( + const ctx = try self.allocator.create(Context); + const userName = try std.fmt.allocPrint( self.allocator, "{s}{d}", .{ self.usernamePrefix, self.contexts.items.len }, @@ -202,7 +202,7 @@ pub fn main() !void { var gpa = std.heap.GeneralPurposeAllocator(.{ .thread_safe = true, }){}; - var allocator = gpa.allocator(); + const allocator = gpa.allocator(); GlobalContextManager = ContextManager.init(allocator, "chatroom", "user-"); defer GlobalContextManager.deinit();