41 lines
1.1 KiB
Zig
41 lines
1.1 KiB
Zig
const std = @import("std");
|
|
const zap = @import("zap");
|
|
|
|
const msg_queue = @import("../msg_queue/root.zig");
|
|
|
|
const models = @import("models/root.zig");
|
|
const endpoints = @import("endpoints/root.zig");
|
|
const stores = @import("stores/root.zig");
|
|
|
|
fn onRequest(r: zap.Request) !void {
|
|
_ = r;
|
|
}
|
|
|
|
pub fn start(allocator: std.mem.Allocator, threads: i16, port: u16, queue: *msg_queue.MsgQueueUnmanaged(msg_queue.messages.BlockUpdate)) !void {
|
|
var listener = zap.Endpoint.Listener.init(allocator, .{
|
|
.port = port,
|
|
.on_request = onRequest,
|
|
.log = true,
|
|
});
|
|
defer listener.deinit();
|
|
|
|
const block_update_queue_store = stores.BlockUpdateQueue{
|
|
.queue = queue,
|
|
};
|
|
|
|
var block_endpoint = endpoints.Block.init(
|
|
allocator,
|
|
&block_update_queue_store,
|
|
std.fmt.comptimePrint("/api/{s}", .{endpoints.Block.default_path}),
|
|
);
|
|
|
|
try listener.register(&block_endpoint);
|
|
|
|
try listener.listen();
|
|
std.log.info("Listening on 0.0.0.0:{d}", .{port});
|
|
|
|
zap.start(.{
|
|
.threads = threads,
|
|
.workers = 1,
|
|
});
|
|
}
|