diff options
Diffstat (limited to 'web/main.zig')
| -rw-r--r-- | web/main.zig | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/web/main.zig b/web/main.zig index 8c3d6ad..eaf6804 100644 --- a/web/main.zig +++ b/web/main.zig @@ -200,7 +200,10 @@ pub fn main(init: std.process.Init) !void { if ((!std.mem.eql(u8, origin_uri.scheme, "https") and !std.mem.eql(u8, origin_uri.scheme, "http")) or origin_uri.host == null or origin_uri.user != null or origin_uri.password != null or origin_uri.path.percent_encoded.len != 0 or origin_uri.query != null or origin_uri.fragment != null) return error.InvalidOrigin; - const browser_config = try std.json.Stringify.valueAlloc(allocator, .{ .user = user, .tree = tree }, .{}); + const browser_config = if (cat != null) + try std.json.Stringify.valueAlloc(allocator, .{ .user = user, .tree = tree, .catalog = true }, .{}) + else + try std.json.Stringify.valueAlloc(allocator, .{ .user = user, .tree = tree }, .{}); var app: App = .{ .io = io, .m = &m, .catalog = cat, .config = .{ .host = host, @@ -402,8 +405,6 @@ fn serveHttp(s: *Session) !void { if (app.catalog) |c| { if (request.head.method != .GET and request.head.method != .HEAD and origin != null and !same_origin) return respond(&request, "Unexpected Origin\n", "text/plain", .forbidden); - if (std.mem.eql(u8, path, "/")) return respond(&request, @embedFile("static/catalog.html"), "text/html; charset=utf-8", .ok); - if (std.mem.eql(u8, path, "/_cloud9/catalog.js")) return respond(&request, @embedFile("static/catalog.js"), "text/javascript", .ok); if (std.mem.eql(u8, path, "/_cloud9/catalog.json")) { var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); defer arena.deinit(); @@ -441,6 +442,7 @@ fn serveHttp(s: *Session) !void { return respond(&request, "Use GET\n", "text/plain", .method_not_allowed); if (std.mem.eql(u8, path, "/_cloud9/config.json")) return respond(&request, config.browser_config, "application/json", .ok); if (std.mem.eql(u8, path, "/_cloud9/app.mjs")) return respond(&request, @embedFile("static/app.mjs"), "text/javascript; charset=utf-8", .ok); + if (std.mem.eql(u8, path, "/_cloud9/catalog.mjs")) return respond(&request, @embedFile("static/catalog.mjs"), "text/javascript; charset=utf-8", .ok); if (std.mem.eql(u8, path, "/_cloud9/client.mjs")) return respond(&request, @embedFile("static/client.mjs"), "text/javascript; charset=utf-8", .ok); if (std.mem.eql(u8, path, "/_cloud9/style.css")) return respond(&request, @embedFile("static/style.css"), "text/css; charset=utf-8", .ok); if (std.mem.eql(u8, path, "/_cloud9/cloud9.wasm")) return respond(&request, @embedFile("client.wasm"), "application/wasm", .ok); |
