mirror of
https://github.com/zigzap/zap.git
synced 2025-10-20 15:14:08 +00:00
lil progress
This commit is contained in:
parent
80678c1cf9
commit
1174a4946d
3 changed files with 15 additions and 5 deletions
|
@ -53,7 +53,7 @@ pub fn addFacilio(exe: *std.build.LibExeObjStep) !void {
|
|||
if (b.is_release) try flags.append("-Os");
|
||||
try flags.append("-Wno-return-type-c-linkage");
|
||||
try flags.append("-fno-sanitize=undefined");
|
||||
|
||||
try flags.append("-DFIO_OVERRIDE_MALLOC");
|
||||
exe.addIncludePath("./src/deps/facilio/libdump/all");
|
||||
|
||||
// Add C
|
||||
|
|
|
@ -7,15 +7,21 @@ fn on_request(request: [*c]zap.C.http_s) callconv(.C) void {
|
|||
}
|
||||
|
||||
pub fn main() !void {
|
||||
std.debug.print("debug1\n", .{});
|
||||
// configure
|
||||
var listen_settings = zap.ListenSettings.init();
|
||||
var listen_settings: zap.ListenSettings = .{};
|
||||
std.debug.print("debug2\n", .{});
|
||||
listen_settings.on_request = on_request;
|
||||
listen_settings.log = true;
|
||||
|
||||
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", .{});
|
||||
|
||||
// start working
|
||||
zap.start(.{
|
||||
.threads = 4,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// zig type definitions for facilio lib
|
||||
// or maybe let's just make it zap directly...
|
||||
|
||||
const std = @import("std");
|
||||
pub const C = @cImport({
|
||||
@cInclude("http.h");
|
||||
@cInclude("fio.h");
|
||||
|
@ -34,8 +35,7 @@ pub fn listen(port: [*c]const u8, interface: [*c]const u8, settings: ListenSetti
|
|||
}
|
||||
pfolder = pf.ptr;
|
||||
}
|
||||
|
||||
if (C.http_listen(port, interface, .{
|
||||
var x: C.http_settings_s = .{
|
||||
.on_request = settings.on_request,
|
||||
.on_upgrade = settings.on_upgrade,
|
||||
.on_response = settings.on_response,
|
||||
|
@ -55,7 +55,11 @@ pub fn listen(port: [*c]const u8, interface: [*c]const u8, settings: ListenSetti
|
|||
.ws_timeout = 0,
|
||||
.log = if (settings.log) 1 else 0,
|
||||
.is_client = 0,
|
||||
}) == -1) {
|
||||
};
|
||||
// TODO: BUG: without this print statement, -Drelease* loop forever
|
||||
// in debug2 and debug3
|
||||
std.debug.print("X\n", .{});
|
||||
if (C.http_listen(port, interface, x) == -1) {
|
||||
return error.ListenError;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue