diff --git a/src/main/main.zig b/src/main/main.zig index d6b8877..30deb06 100644 --- a/src/main/main.zig +++ b/src/main/main.zig @@ -10,7 +10,7 @@ const RouteArgs = http.RouteArgs; const router = Router{ .routes = &[_]Route{ Route.new(.GET, "/healthcheck", healthcheck), - Route.new(.GET, "/", getNote), + Route.new(.GET, "/:id", getNote), }, }; @@ -44,8 +44,9 @@ fn respondJson(ctx: *http.server.Context, value: anytype, alloc: std.mem.Allocat try stream.finish(); } -fn getNote(srv: *RequestServer, ctx: *http.server.Context, _: RouteArgs) !void { - const note = try srv.db.getNote("1", srv.alloc); +fn getNote(srv: *RequestServer, ctx: *http.server.Context, args: RouteArgs) !void { + const id = args.get("id").?; + const note = try srv.db.getNote(id, srv.alloc); defer db.free(srv.alloc, note); try respondJson(ctx, note, srv.alloc);