From 51307d973255e32ec1440083dee383e8b2cd8878 Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Sat, 6 Jun 2026 07:57:50 +0200 Subject: Implement static handler and synchronous server handling --- src/main.zig | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/main.zig') diff --git a/src/main.zig b/src/main.zig index 4b2b025..6d2b9ce 100644 --- a/src/main.zig +++ b/src/main.zig @@ -8,6 +8,8 @@ const http = @import("http"); const html = @import("html"); const z = @import("z"); +const Static = http.handler.Static; + const components = @import("web/component/root.zig").components; const document: html.Element = .native(.html, .{}, .children(&.{ @@ -26,9 +28,17 @@ const document: html.Element = .native(.html, .{}, .children(&.{ })), })); +const routes: http.RouteSet = .init(&.{ + Static(.index, document.toDocument()).interface(), +}); + pub fn main(init: std.process.Init) !void { - var server: http.Server = try .init(init.gpa, try .parseLiteral("0.0.0.0:8080")); - try server.serve(comptime document.toDocument()); + var server: http.Server = try .init( + init.gpa, + try .parseLiteral("0.0.0.0:8080"), + routes, + ); + try server.serve(init.gpa); } test { -- cgit v1.2.3-70-g09d2