mirror of
https://github.com/zigzap/zap.git
synced 2025-10-20 23:24:09 +00:00
added facilio.start()
This commit is contained in:
parent
51b84bd198
commit
be41be49ea
2 changed files with 10 additions and 6 deletions
|
@ -1,14 +1,14 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const facilio = @import("facilio");
|
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", .{});
|
std.debug.print("REQUEST!\n", .{});
|
||||||
var msg: []const u8 = "Hello from ZAP!";
|
var msg: []const u8 = "Hello from ZAP!";
|
||||||
_ = facilio.sendBody(request, msg);
|
_ = facilio.sendBody(request, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() void {
|
pub fn main() void {
|
||||||
if (facilio.Http.http_listen("3000", null, .{
|
if (facilio.C.http_listen("3000", null, .{
|
||||||
.on_request = on_request,
|
.on_request = on_request,
|
||||||
.log = 1,
|
.log = 1,
|
||||||
.on_upgrade = null,
|
.on_upgrade = null,
|
||||||
|
@ -33,7 +33,7 @@ pub fn main() void {
|
||||||
std.debug.print("Listening failed\n", .{});
|
std.debug.print("Listening failed\n", .{});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
facilio.Http.fio_start(.{
|
facilio.start(.{
|
||||||
.threads = 4,
|
.threads = 4,
|
||||||
.workers = 4,
|
.workers = 4,
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
// zig type definitions for facilio lib
|
// zig type definitions for facilio lib
|
||||||
|
|
||||||
pub const Http = @cImport({
|
pub const C = @cImport({
|
||||||
@cInclude("http.h");
|
@cInclude("http.h");
|
||||||
@cInclude("fio.h");
|
@cInclude("fio.h");
|
||||||
});
|
});
|
||||||
|
|
||||||
pub fn sendBody(request: [*c]Http.http_s, body: []const u8) void {
|
pub fn sendBody(request: [*c]C.http_s, body: []const u8) void {
|
||||||
_ = Http.http_send_body(request, @intToPtr(
|
_ = C.http_send_body(request, @intToPtr(
|
||||||
*anyopaque,
|
*anyopaque,
|
||||||
@ptrToInt(body.ptr),
|
@ptrToInt(body.ptr),
|
||||||
), body.len);
|
), body.len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn start(args: C.fio_start_args) void {
|
||||||
|
C.fio_start(args);
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue