Skip to content

Commit

Permalink
registerDispatcher function added to router
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve🔆 committed Nov 22, 2024
1 parent 3661935 commit 93119c4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/router.zig
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ pub fn Router(comptime Handler: type, comptime Action: type) type {
};
}

// Return a RouteConfig with the given dispatcher function embedded
pub fn registerDispatcher(_: Self, dispatcher: Dispatcher) RC {
return RC{
.dispatcher = dispatcher,
};
}

pub fn get(self: *Self, path: []const u8, action: Action, config: RC) void {
self.tryGet(path, action, config) catch @panic("failed to create route");
}
Expand Down

0 comments on commit 93119c4

Please sign in to comment.