Init
This commit is contained in:
commit
e70a04ac16
19 changed files with 576 additions and 0 deletions
41
src/web/root.zig
Normal file
41
src/web/root.zig
Normal file
|
@ -0,0 +1,41 @@
|
|||
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,
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue