remove router for now
This commit is contained in:
parent
a9eb927570
commit
c774e56828
1 changed files with 10 additions and 7 deletions
17
src/main.zig
17
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);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue