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:
parent
856d531642
commit
d91df53ee7
3 changed files with 9 additions and 5 deletions
|
@ -61,6 +61,7 @@ pub fn addFacilio(exe: *std.build.LibExeObjStep) !void {
|
||||||
try flags.append("-Wno-return-type-c-linkage");
|
try flags.append("-Wno-return-type-c-linkage");
|
||||||
try flags.append("-fno-sanitize=undefined");
|
try flags.append("-fno-sanitize=undefined");
|
||||||
try flags.append("-DFIO_OVERRIDE_MALLOC");
|
try flags.append("-DFIO_OVERRIDE_MALLOC");
|
||||||
|
try flags.append("-DFIO_HTTP_EXACT_LOGGING");
|
||||||
exe.addIncludePath("./src/deps/facilio/libdump/all");
|
exe.addIncludePath("./src/deps/facilio/libdump/all");
|
||||||
|
|
||||||
// Add C
|
// Add C
|
||||||
|
|
|
@ -3,24 +3,25 @@ const zap = @import("facilio");
|
||||||
|
|
||||||
fn on_request(request: [*c]zap.C.http_s) callconv(.C) void {
|
fn on_request(request: [*c]zap.C.http_s) callconv(.C) void {
|
||||||
std.debug.print("GOT A REQUEST!\n", .{});
|
std.debug.print("GOT A REQUEST!\n", .{});
|
||||||
|
// std.time.sleep(5 * 1000 * 1000);
|
||||||
_ = zap.sendBody(request, "Hello from ZAP!!!");
|
_ = zap.sendBody(request, "Hello from ZAP!!!");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() !void {
|
pub fn main() !void {
|
||||||
std.debug.print("debug1\n", .{});
|
// std.debug.print("debug1\n", .{});
|
||||||
// configure
|
// configure
|
||||||
var listen_settings: zap.ListenSettings = .{};
|
var listen_settings: zap.ListenSettings = .{};
|
||||||
std.debug.print("debug2\n", .{});
|
// std.debug.print("debug2\n", .{});
|
||||||
listen_settings.on_request = on_request;
|
listen_settings.on_request = on_request;
|
||||||
listen_settings.log = true;
|
listen_settings.log = true;
|
||||||
|
|
||||||
std.debug.print("debug3\n", .{});
|
// std.debug.print("debug3\n", .{});
|
||||||
|
|
||||||
// listen
|
// listen
|
||||||
try zap.listen("3000", null, listen_settings);
|
try zap.listen("3000", null, listen_settings);
|
||||||
std.debug.print("Listening on port 3000\n", .{});
|
std.debug.print("Listening on port 3000\n", .{});
|
||||||
|
|
||||||
std.debug.print("debug4\n", .{});
|
// std.debug.print("debug4\n", .{});
|
||||||
|
|
||||||
// start working
|
// start working
|
||||||
zap.start(.{
|
zap.start(.{
|
||||||
|
|
|
@ -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
|
// TODO: BUG: without this print statement, -Drelease* loop forever
|
||||||
// in debug2 and debug3
|
// 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) {
|
if (C.http_listen(port, interface, x) == -1) {
|
||||||
return error.ListenError;
|
return error.ListenError;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue