1
0
Fork 0
mirror of https://github.com/zigzap/zap.git synced 2025-10-20 23:24:09 +00:00

introduced sleep workaround and exact logging

This commit is contained in:
Rene Schallner 2023-01-11 23:09:04 +01:00
parent 856d531642
commit d91df53ee7
3 changed files with 9 additions and 5 deletions

View file

@ -61,6 +61,7 @@ pub fn addFacilio(exe: *std.build.LibExeObjStep) !void {
try flags.append("-Wno-return-type-c-linkage");
try flags.append("-fno-sanitize=undefined");
try flags.append("-DFIO_OVERRIDE_MALLOC");
try flags.append("-DFIO_HTTP_EXACT_LOGGING");
exe.addIncludePath("./src/deps/facilio/libdump/all");
// Add C

View file

@ -3,24 +3,25 @@ const zap = @import("facilio");
fn on_request(request: [*c]zap.C.http_s) callconv(.C) void {
std.debug.print("GOT A REQUEST!\n", .{});
// std.time.sleep(5 * 1000 * 1000);
_ = zap.sendBody(request, "Hello from ZAP!!!");
}
pub fn main() !void {
std.debug.print("debug1\n", .{});
// std.debug.print("debug1\n", .{});
// configure
var listen_settings: zap.ListenSettings = .{};
std.debug.print("debug2\n", .{});
// std.debug.print("debug2\n", .{});
listen_settings.on_request = on_request;
listen_settings.log = true;
std.debug.print("debug3\n", .{});
// std.debug.print("debug3\n", .{});
// listen
try zap.listen("3000", null, listen_settings);
std.debug.print("Listening on port 3000\n", .{});
std.debug.print("debug4\n", .{});
// std.debug.print("debug4\n", .{});
// start working
zap.start(.{

View file

@ -58,7 +58,9 @@ pub fn listen(port: [*c]const u8, interface: [*c]const u8, settings: ListenSetti
};
// TODO: BUG: without this print statement, -Drelease* loop forever
// in debug2 and debug3
std.debug.print("X\n", .{});
// std.debug.print("X\n", .{});
std.time.sleep(500 * 1000 * 1000);
if (C.http_listen(port, interface, x) == -1) {
return error.ListenError;
}