mirror of
https://github.com/zigzap/zap.git
synced 2025-10-20 15:14:08 +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 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,
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue