1
0
Fork 0
mirror of https://github.com/zigzap/zap.git synced 2025-10-20 15:14:08 +00:00
zap/examples/hello/hello.zig
Rene Schallner 1174a4946d lil progress
2023-01-11 21:21:25 +01:00

30 lines
757 B
Zig

const std = @import("std");
const zap = @import("facilio");
fn on_request(request: [*c]zap.C.http_s) callconv(.C) void {
std.debug.print("GOT A REQUEST!\n", .{});
_ = zap.sendBody(request, "Hello from ZAP!!!");
}
pub fn main() !void {
std.debug.print("debug1\n", .{});
// configure
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,
.workers = 4,
});
}