╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ serve.zig ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
174 fn h(ctx: Context, stream: std.Io.net.Stream) void { 175 defer stream.close(ctx.io); 176 web.handleConnection(ctx.io, ctx.allocator, stream, ctx.host, ctx.err) catch |request_err| { 177 serve_common.logError(ctx.err, "web ui request failed: {s}\n", .{@errorName(request_err)}); 178 }; 179 } 180 }.h; 181 182 serve_common.runListener(io, net_server, tasks, err, "web ui", Context{ 183 .io = io, 184 .allocator = allocator, 185 .host = host, 186 .err = err, 187 }, handle); 188 } 189 190 fn parseListenAddress(value: []const u8) !ListenAddress { 191 const colon = std.mem.lastIndexOfScalar(u8, value, ':') orelse return error.InvalidListenAddress; 192 if (colon == 0 or colon + 1 >= value.len) return error.InvalidListenAddress; 193 const port = try std.fmt.parseInt(u16, value[colon + 1 ..], 10); 194 return .{ .host = value[0..colon], .port = port }; 195 } 196