From be41be49ea193f3283a1aa375e38497af19b0a3f Mon Sep 17 00:00:00 2001 From: Rene Schallner Date: Wed, 11 Jan 2023 19:35:42 +0100 Subject: [PATCH] added facilio.start() --- examples/hello/hello.zig | 6 +++--- src/deps/facilio.zig | 10 +++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/examples/hello/hello.zig b/examples/hello/hello.zig index a2f1d63..c22c2a0 100644 --- a/examples/hello/hello.zig +++ b/examples/hello/hello.zig @@ -1,14 +1,14 @@ const std = @import("std"); const facilio = @import("facilio"); -fn on_request(request: [*c]facilio.Http.http_s) callconv(.C) void { +fn on_request(request: [*c]facilio.C.http_s) callconv(.C) void { std.debug.print("REQUEST!\n", .{}); var msg: []const u8 = "Hello from ZAP!"; _ = facilio.sendBody(request, msg); } pub fn main() void { - if (facilio.Http.http_listen("3000", null, .{ + if (facilio.C.http_listen("3000", null, .{ .on_request = on_request, .log = 1, .on_upgrade = null, @@ -33,7 +33,7 @@ pub fn main() void { std.debug.print("Listening failed\n", .{}); return; } - facilio.Http.fio_start(.{ + facilio.start(.{ .threads = 4, .workers = 4, }); diff --git a/src/deps/facilio.zig b/src/deps/facilio.zig index 5367af3..96002a0 100644 --- a/src/deps/facilio.zig +++ b/src/deps/facilio.zig @@ -1,13 +1,17 @@ // zig type definitions for facilio lib -pub const Http = @cImport({ +pub const C = @cImport({ @cInclude("http.h"); @cInclude("fio.h"); }); -pub fn sendBody(request: [*c]Http.http_s, body: []const u8) void { - _ = Http.http_send_body(request, @intToPtr( +pub fn sendBody(request: [*c]C.http_s, body: []const u8) void { + _ = C.http_send_body(request, @intToPtr( *anyopaque, @ptrToInt(body.ptr), ), body.len); } + +pub fn start(args: C.fio_start_args) void { + C.fio_start(args); +}