1
0
Fork 0
mirror of https://github.com/zigzap/zap.git synced 2025-10-20 15:14:08 +00:00

"fixed" release build errors in mustache example

This commit is contained in:
Rene Schallner 2023-03-10 11:58:51 +01:00
parent 615d90b8f4
commit 1fcb11f03a
2 changed files with 18 additions and 9 deletions

View file

@ -25,12 +25,15 @@ fn on_request(r: zap.SimpleRequest) void {
},
});
defer ret.deinit();
r.setContentType(.TEXT) catch return;
if (r.setContentType(.TEXT)) {
if (ret.str()) |s| {
r.sendBody(s) catch return;
} else {
r.sendBody("<html><body><h1>MustacheBuild() failed!</h1></body></html>") catch return;
}
} else |err| {
std.debug.print("Error while setting content type: {}\n", .{err});
}
}
pub fn main() !void {
@ -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", .{});

View file

@ -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: