]> jxnshi.xyz Git - jxnshi.xyz.git/commitdiff
Change clone command
authorjxnshi <jxnshi@proton.me>
Sat, 4 Jan 2025 20:13:09 +0000 (20:13 +0000)
committerjxnshi <jxnshi@proton.me>
Sat, 4 Jan 2025 20:13:09 +0000 (20:13 +0000)
src/main.zig

index 67857a5f63596b72e83564ada2050cab6493be64..5e32cd059ad5563b953751d8861c8fd2f82f2c22 100644 (file)
@@ -39,6 +39,8 @@ fn handleClient(parent_allocator: std.mem.Allocator, connection: std.net.Server.
     var public_dir = try cwd.openDir("public", .{});
     defer public_dir.close();
 
+    var status = std.http.Status.ok;
+
     while (true) {
         if (server.state != .ready) {
             return;
@@ -109,7 +111,7 @@ fn handleClient(parent_allocator: std.mem.Allocator, connection: std.net.Server.
 
                     var git_iter = git_dir.iterate();
 
-                    try temp_buffer_writer.writeAll("<code>git clone git@jxnshi.xyz:/srv/git/repo.git</code>");
+                    try temp_buffer_writer.writeAll("<code>git clone git://jxnshi.xyz/repo-name.git</code>");
                     try temp_buffer_writer.writeAll("<ul id=\"repos-list\">\n");
 
                     while (try git_iter.next()) |entry| {
@@ -198,6 +200,7 @@ fn handleClient(parent_allocator: std.mem.Allocator, connection: std.net.Server.
                 const not_found_file_reader = not_found_file.reader();
 
                 try not_found_file_reader.readAllArrayList(&temp_buffer, std.math.maxInt(usize));
+                status = .not_found;
             }
 
             try send_buffer.resize(layout_buffer.items.len + temp_buffer.items.len - 3);
@@ -206,7 +209,12 @@ fn handleClient(parent_allocator: std.mem.Allocator, connection: std.net.Server.
 
         std.log.info("Responded in {d:.2}ms.", .{timer.read() / 1_000_000});
 
-        try request.respond(send_buffer.items, .{});
+        try request.respond(
+            send_buffer.items,
+            .{
+                .status = status,
+            },
+        );
     }
 }