mirror of
https://github.com/zigzap/zap.git
synced 2025-10-20 15:14:08 +00:00
Fixup examples/http_params, examples/websockets
This commit is contained in:
parent
c74f699252
commit
da420b4114
2 changed files with 10 additions and 9 deletions
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Reference in a new issue