mirror of
https://github.com/zigzap/zap.git
synced 2025-10-20 15:14:08 +00:00
added wrapper facilio.sendBody
This commit is contained in:
parent
db33bd9b40
commit
51b84bd198
2 changed files with 12 additions and 8 deletions
|
@ -1,17 +1,14 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const facilio = @import("facilio").Http;
|
const facilio = @import("facilio");
|
||||||
|
|
||||||
fn on_request(request: [*c]facilio.http_s) callconv(.C) void {
|
fn on_request(request: [*c]facilio.Http.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.http_send_body(request, @intToPtr(
|
_ = facilio.sendBody(request, msg);
|
||||||
*anyopaque,
|
|
||||||
@ptrToInt(msg.ptr),
|
|
||||||
), msg.len);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() void {
|
pub fn main() void {
|
||||||
if (facilio.http_listen("3000", null, .{
|
if (facilio.Http.http_listen("3000", null, .{
|
||||||
.on_request = on_request,
|
.on_request = on_request,
|
||||||
.log = 1,
|
.log = 1,
|
||||||
.on_upgrade = null,
|
.on_upgrade = null,
|
||||||
|
@ -36,7 +33,7 @@ pub fn main() void {
|
||||||
std.debug.print("Listening failed\n", .{});
|
std.debug.print("Listening failed\n", .{});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
facilio.fio_start(.{
|
facilio.Http.fio_start(.{
|
||||||
.threads = 4,
|
.threads = 4,
|
||||||
.workers = 4,
|
.workers = 4,
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,3 +4,10 @@ pub const Http = @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 {
|
||||||
|
_ = Http.http_send_body(request, @intToPtr(
|
||||||
|
*anyopaque,
|
||||||
|
@ptrToInt(body.ptr),
|
||||||
|
), body.len);
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue