1
0
Fork 0
mirror of https://github.com/zigzap/zap.git synced 2025-10-21 07:34:08 +00:00

fixed hello_json

This commit is contained in:
Rene Schallner 2023-01-13 18:18:36 +01:00
parent fd2009d7a0
commit ac9af50831

View file

@ -39,8 +39,8 @@ fn setupUserData(a: std.mem.Allocator) !void {
try users.put(2, .{ .first_name = "Your", .last_name = "Mom" }); try users.put(2, .{ .first_name = "Your", .last_name = "Mom" });
} }
fn stringify(value: anytype, options: std.json.StringifyOptions) ?[]const u8 {
var buf: [100]u8 = undefined; var buf: [100]u8 = undefined;
fn stringify(value: anytype, options: std.json.StringifyOptions) ?[]const u8 {
var fba = std.heap.FixedBufferAllocator.init(&buf); var fba = std.heap.FixedBufferAllocator.init(&buf);
var string = std.ArrayList(u8).init(fba.allocator()); var string = std.ArrayList(u8).init(fba.allocator());
if (std.json.stringify(value, options, string.writer())) { if (std.json.stringify(value, options, string.writer())) {
@ -60,7 +60,15 @@ pub fn main() !void {
}); });
try listener.listen(); try listener.listen();
std.debug.print("Listening on 0.0.0.0:3000\n", .{}); std.debug.print(
\\ Listening on 0.0.0.0:3000
\\
\\ Check out:
\\ http://localhost:3000/user/1 # -- first user
\\ http://localhost:3000/user/2 # -- second user
\\ http://localhost:3000/user/3 # -- non-existing user
\\
, .{});
// start worker threads // start worker threads
zap.start(.{ zap.start(.{