From 1fcb11f03a2a9f37b8eed83340dfd8327a88b085 Mon Sep 17 00:00:00 2001 From: Rene Schallner Date: Fri, 10 Mar 2023 11:58:51 +0100 Subject: [PATCH] "fixed" release build errors in mustache example --- examples/mustache/mustache.zig | 21 ++++++++++++--------- src/zap.zig | 6 ++++++ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/examples/mustache/mustache.zig b/examples/mustache/mustache.zig index d6be8fb..f28f92a 100644 --- a/examples/mustache/mustache.zig +++ b/examples/mustache/mustache.zig @@ -25,11 +25,14 @@ fn on_request(r: zap.SimpleRequest) void { }, }); defer ret.deinit(); - r.setContentType(.TEXT) catch return; - if (ret.str()) |s| { - r.sendBody(s) catch return; - } else { - r.sendBody("

MustacheBuild() failed!

") catch return; + if (r.setContentType(.TEXT)) { + if (ret.str()) |s| { + r.sendBody(s) catch return; + } else { + r.sendBody("

MustacheBuild() failed!

") catch return; + } + } else |err| { + std.debug.print("Error while setting content type: {}\n", .{err}); } } @@ -42,12 +45,12 @@ pub fn main() !void { }); try listener.listen(); - zap.enableDebugLog(); - zap.debug("ZAP debug logging is on\n", .{}); + // zap.enableDebugLog(); + // zap.debug("ZAP debug logging is on\n", .{}); // we can also use facilio logging - zap.Log.fio_set_log_level(zap.Log.fio_log_level_debug); - zap.Log.fio_log_debug("ZAP debug logging is on\n"); + // zap.Log.fio_set_log_level(zap.Log.fio_log_level_debug); + // zap.Log.fio_log_debug("hello from fio\n"); std.debug.print("Listening on 0.0.0.0:3000\n", .{}); diff --git a/src/zap.zig b/src/zap.zig index d369f20..f6505f3 100644 --- a/src/zap.zig +++ b/src/zap.zig @@ -138,6 +138,12 @@ pub const SimpleRequest = struct { }; debug("setHeader: vname = {}\n", .{vname}); const ret = fio.http_set_header2(self.h, hname, vname); + + // FIXME without the following if, we get errors in release builds + // at least we don't have to log unconditionally + if (ret == -1) { + std.debug.print("***************** zap.zig:145\n", .{}); + } debug("setHeader: ret = {}\n", .{ret}); // Note to self: