usrctx: use ctx http client with xhr

This commit is contained in:
Pierre Tachoire
2024-04-23 12:09:41 +02:00
parent c2e64c131a
commit 00d75584db
6 changed files with 40 additions and 13 deletions

View File

@@ -29,6 +29,7 @@ const html_test = @import("html_test.zig").html;
pub const Types = jsruntime.reflect(apiweb.Interfaces);
pub const UserContext = apiweb.UserContext;
const Client = @import("async/Client.zig");
var doc: *parser.DocumentHTML = undefined;
@@ -40,8 +41,12 @@ fn execJS(
try js_env.start(alloc);
defer js_env.stop();
var cli = Client{ .allocator = alloc, .loop = js_env.nat_ctx.loop };
defer cli.deinit();
try js_env.setUserContext(UserContext{
.document = doc,
.httpClient = &cli,
});
var storageShelf = storage.Shelf.init(alloc);