From f6799be60fdd1b14ab60fc23d4b8a2b7a0e6c8cc Mon Sep 17 00:00:00 2001 From: Rene Schallner Date: Fri, 28 Jun 2024 12:39:54 +0200 Subject: [PATCH 1/3] fix hash --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1407359..d86b7fc 100644 --- a/README.md +++ b/README.md @@ -277,7 +277,7 @@ To add zap to `build.zig.zon`: // zap v0.7.0 .zap = .{ .url = "https://github.com/zigzap/zap/archive/refs/tags/v0.7.0.tar.gz", - .hash = "12203126ff24e8018655eb7444c91f0d527d1213af16fcf2a578281abc994d01cc46", + .hash = "12209936c3333b53b53edcf453b1670babb9ae8c2197b1ca627c01e72670e20c1a21", }, }, .paths = .{ From 33a041e02cdb7ccd7422ff8385614f975ab63a13 Mon Sep 17 00:00:00 2001 From: Rene Schallner Date: Mon, 14 Oct 2024 22:26:18 +0200 Subject: [PATCH 2/3] update to zig master --- src/mustache.zig | 28 ++++++++++++++-------------- src/request.zig | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/mustache.zig b/src/mustache.zig index 5b75d88..2670910 100644 --- a/src/mustache.zig +++ b/src/mustache.zig @@ -139,7 +139,7 @@ pub const BuildResult = struct { // See `fiobjectify` for more information. pub fn build(self: *Self, data: anytype) BuildResult { const T = @TypeOf(data); - if (@typeInfo(T) != .Struct) { + if (@typeInfo(T) != .@"struct") { @compileError("No struct: '" ++ @typeName(T) ++ "'"); } @@ -157,29 +157,29 @@ fn fiobjectify( ) fio.FIOBJ { const T = @TypeOf(value); switch (@typeInfo(T)) { - .Float, .ComptimeFloat => { + .float, .comptime_float => { return fio.fiobj_float_new(value); }, - .Int, .ComptimeInt => { + .int, .comptime_int => { return fio.fiobj_num_new_bignum(value); }, - .Bool => { + .bool => { return if (value) fio.fiobj_true() else fio.fiobj_false(); }, - .Null => { + .null => { return 0; }, - .Optional => { + .optional => { if (value) |payload| { return fiobjectify(payload); } else { return fiobjectify(null); } }, - .Enum => { + .@"enum" => { return fio.fiobj_num_new_bignum(@intFromEnum(value)); }, - .Union => { + .@"union" => { const info = @typeInfo(T).Union; if (info.tag_type) |UnionTagType| { inline for (info.fields) |u_field| { @@ -191,7 +191,7 @@ fn fiobjectify( @compileError("Unable to fiobjectify untagged union '" ++ @typeName(T) ++ "'"); } }, - .Struct => |S| { + .@"struct" => |S| { // create a new fio hashmap const m = fio.fiobj_hash_new(); // std.debug.print("new struct\n", .{}); @@ -211,10 +211,10 @@ fn fiobjectify( } return m; }, - .ErrorSet => return fiobjectify(@as([]const u8, @errorName(value))), - .Pointer => |ptr_info| switch (ptr_info.size) { + .error_set => return fiobjectify(@as([]const u8, @errorName(value))), + .pointer => |ptr_info| switch (ptr_info.size) { .One => switch (@typeInfo(ptr_info.child)) { - .Array => { + .array => { const Slice = []const std.meta.Elem(ptr_info.child); return fiobjectify(@as(Slice, value)); }, @@ -239,8 +239,8 @@ fn fiobjectify( }, else => @compileError("Unable to fiobjectify type '" ++ @typeName(T) ++ "'"), }, - .Array => return fiobjectify(&value), - .Vector => |info| { + .array => return fiobjectify(&value), + .vector => |info| { const array: [info.len]info.child = value; return fiobjectify(&array); }, diff --git a/src/request.zig b/src/request.zig index e0d7668..07050ef 100644 --- a/src/request.zig +++ b/src/request.zig @@ -339,7 +339,7 @@ pub fn _internal_sendError(self: *const Self, err: anyerror, err_trace: ?std.bui if (err_trace) |trace| { const debugInfo = try std.debug.getSelfDebugInfo(); const ttyConfig: std.io.tty.Config = .no_color; - try std.debug.writeStackTrace(trace, writer, fba.allocator(), debugInfo, ttyConfig); + try std.debug.writeStackTrace(trace, writer, debugInfo, ttyConfig); } try self.sendBody(string.items); From 425680de2e4e60098657d930c2d47d6b8569828a Mon Sep 17 00:00:00 2001 From: Rene Schallner Date: Sun, 20 Oct 2024 23:29:16 +0200 Subject: [PATCH 3/3] Revert "EndpointHandler: de-morgan logic for useRoutes" This reverts commit 9543ede15fc9ad038ec4839628c886b124580983. --- src/middleware.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/middleware.zig b/src/middleware.zig index 3fa734c..c094fee 100644 --- a/src/middleware.zig +++ b/src/middleware.zig @@ -99,7 +99,7 @@ pub fn EndpointHandler(comptime HandlerType: anytype, comptime ContextType: anyt pub fn onRequest(handler: *HandlerType, r: zap.Request, context: *ContextType) bool { const self: *Self = @fieldParentPtr("handler", handler); r.setUserContext(context); - if (self.options.checkPath and + if (!self.options.checkPath or std.mem.startsWith(u8, r.path orelse "", self.endpoint.settings.path)) { self.endpoint.onRequest(r);