mirror of
https://github.com/zigzap/zap.git
synced 2025-10-20 23:24:09 +00:00
don't pollute global namespace with fio
This commit is contained in:
parent
eca4d511f0
commit
724ce87bd2
6 changed files with 82 additions and 77 deletions
|
@ -73,7 +73,7 @@ const Handler = struct {
|
||||||
defer s.deinit();
|
defer s.deinit();
|
||||||
std.log.info("?terminate={s}\n", .{s.str});
|
std.log.info("?terminate={s}\n", .{s.str});
|
||||||
if (std.mem.eql(u8, s.str, "true")) {
|
if (std.mem.eql(u8, s.str, "true")) {
|
||||||
zap.fio_stop();
|
zap.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else |err| {
|
} else |err| {
|
||||||
|
|
|
@ -86,7 +86,7 @@ pub fn main() !void {
|
||||||
if (maybe_str) |*s| {
|
if (maybe_str) |*s| {
|
||||||
defer s.deinit();
|
defer s.deinit();
|
||||||
if (std.mem.eql(u8, s.str, "true")) {
|
if (std.mem.eql(u8, s.str, "true")) {
|
||||||
zap.fio_stop();
|
zap.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else |err| {
|
} else |err| {
|
||||||
|
|
|
@ -111,7 +111,7 @@ fn endpoint_http_get(e: *Endpoints.Endpoint, r: zap.Request) void {
|
||||||
r.sendBody(HTTP_RESPONSE) catch return;
|
r.sendBody(HTTP_RESPONSE) catch return;
|
||||||
received_response = HTTP_RESPONSE;
|
received_response = HTTP_RESPONSE;
|
||||||
std.time.sleep(1 * std.time.ns_per_s);
|
std.time.sleep(1 * std.time.ns_per_s);
|
||||||
zap.fio_stop();
|
zap.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn endpoint_http_unauthorized(e: *Endpoints.Endpoint, r: zap.Request) void {
|
fn endpoint_http_unauthorized(e: *Endpoints.Endpoint, r: zap.Request) void {
|
||||||
|
@ -120,7 +120,7 @@ fn endpoint_http_unauthorized(e: *Endpoints.Endpoint, r: zap.Request) void {
|
||||||
r.sendBody("UNAUTHORIZED ACCESS") catch return;
|
r.sendBody("UNAUTHORIZED ACCESS") catch return;
|
||||||
received_response = "UNAUTHORIZED";
|
received_response = "UNAUTHORIZED";
|
||||||
std.time.sleep(1 * std.time.ns_per_s);
|
std.time.sleep(1 * std.time.ns_per_s);
|
||||||
zap.fio_stop();
|
zap.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -165,7 +165,7 @@ fn makeRequest(a: std.mem.Allocator, url: []const u8, auth: ?ClientAuthReqHeader
|
||||||
std.debug.print("RESPONSE:\n{s}\n", .{buffer[0..len]});
|
std.debug.print("RESPONSE:\n{s}\n", .{buffer[0..len]});
|
||||||
}
|
}
|
||||||
|
|
||||||
zap.fio_stop();
|
zap.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn makeRequestThread(a: std.mem.Allocator, url: []const u8, auth: ?ClientAuthReqHeaderFields) !std.Thread {
|
fn makeRequestThread(a: std.mem.Allocator, url: []const u8, auth: ?ClientAuthReqHeaderFields) !std.Thread {
|
||||||
|
|
|
@ -15,7 +15,7 @@ fn makeRequest(a: std.mem.Allocator, url: []const u8) !void {
|
||||||
|
|
||||||
try req.send(.{});
|
try req.send(.{});
|
||||||
try req.wait();
|
try req.wait();
|
||||||
zap.fio_stop();
|
zap.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn makeRequestThread(a: std.mem.Allocator, url: []const u8) !std.Thread {
|
fn makeRequestThread(a: std.mem.Allocator, url: []const u8) !std.Thread {
|
||||||
|
|
|
@ -22,7 +22,7 @@ fn makeRequest(a: std.mem.Allocator, url: []const u8) !void {
|
||||||
try req.wait();
|
try req.wait();
|
||||||
read_len = try req.readAll(&buffer);
|
read_len = try req.readAll(&buffer);
|
||||||
|
|
||||||
zap.fio_stop();
|
zap.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn makeRequestThread(a: std.mem.Allocator, url: []const u8) !std.Thread {
|
fn makeRequestThread(a: std.mem.Allocator, url: []const u8) !std.Thread {
|
||||||
|
|
|
@ -2,12 +2,14 @@
|
||||||
// or maybe let's just make it zap directly...
|
// or maybe let's just make it zap directly...
|
||||||
|
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const fio = @import("fio.zig");
|
|
||||||
|
/// The facilio C API. No need to use this.
|
||||||
|
pub const fio = @import("fio.zig");
|
||||||
|
|
||||||
/// Server-Side TLS function wrapper
|
/// Server-Side TLS function wrapper
|
||||||
pub const Tls = @import("tls.zig");
|
pub const Tls = @import("tls.zig");
|
||||||
|
|
||||||
pub usingnamespace @import("fio.zig");
|
// pub usingnamespace @import("fio.zig");
|
||||||
pub usingnamespace @import("endpoint.zig");
|
pub usingnamespace @import("endpoint.zig");
|
||||||
pub usingnamespace @import("util.zig");
|
pub usingnamespace @import("util.zig");
|
||||||
pub usingnamespace @import("http.zig");
|
pub usingnamespace @import("http.zig");
|
||||||
|
@ -975,6 +977,8 @@ pub const HttpListener = struct {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Low-level API
|
||||||
|
pub const LowLevel = struct {
|
||||||
/// lower level listening, if you don't want to use a listener but rather use
|
/// lower level listening, if you don't want to use a listener but rather use
|
||||||
/// the listen() function.
|
/// the listen() function.
|
||||||
pub const ListenSettings = struct {
|
pub const ListenSettings = struct {
|
||||||
|
@ -1047,3 +1051,4 @@ pub fn sendBody(request: [*c]fio.http_s, body: []const u8) HttpError!void {
|
||||||
debug("sendBody(): ret = {}\n", .{ret});
|
debug("sendBody(): ret = {}\n", .{ret});
|
||||||
if (ret != -1) return error.HttpSendBody;
|
if (ret != -1) return error.HttpSendBody;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue