From c774e568281a7b5ac36ca47b385e1e8576291b5a Mon Sep 17 00:00:00 2001 From: Jeeves Date: Tue, 26 Mar 2024 16:37:58 -0600 Subject: [PATCH] remove router for now --- src/main.zig | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main.zig b/src/main.zig index c32fccb..7e73432 100644 --- a/src/main.zig +++ b/src/main.zig @@ -17,7 +17,7 @@ pub fn main() !void { }); defer listener.deinit(); - try listener.router.putRoute("/", &handle); + // try listener.router.putRoute("/", &handle); // try listener.router.putRoute("/error", &handleError); // try listener.router.putRoute("//pee", &handleError); // try listener.router.putRoute("/error/*", &handleError); @@ -43,7 +43,8 @@ pub fn Listener(comptime Context: type) type { /// Listen address address: net.Address, /// Main router - router: Router, + // router: Router, + handler: HandlerFn, /// Initialization options pub const Options = struct { @@ -58,12 +59,13 @@ pub fn Listener(comptime Context: type) type { return .{ .address = options.address, .allocator = options.allocator, - .router = Router.init(options.allocator, options.root_handler), + .handler = options.root_handler, + // .router = Router.init(options.allocator, options.root_handler), }; } - pub fn deinit(self: *Self) void { - self.router.deinit(); + pub fn deinit(_: *Self) void { + // self.router.deinit(); } /// Listens for new connections forever @@ -105,8 +107,9 @@ pub fn Listener(comptime Context: type) type { var header_it = req.iterateHeaders(); while (header_it.next()) |header| try event.req.headers.append(&header); - const route = try self.router.getRoute(event.req.uri.path); - try route.handler(&event); + // const route = try self.router.getRoute(event.req.uri.path); + // try route.handler(&event); + try self.handler(&event); try respondFromEvent(&event, &req, allocator); }