From b43985a19308cc47a7af9b74f74efdfc54be7a83 Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Mon, 15 Jun 2026 17:33:47 +0200 Subject: add headers mechanism to response --- src/z/rest.js | 20 ++++++++++++++++++++ src/z/root.zig | 5 ++++- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 src/z/rest.js (limited to 'src/z') diff --git a/src/z/rest.js b/src/z/rest.js new file mode 100644 index 0000000..c14944d --- /dev/null +++ b/src/z/rest.js @@ -0,0 +1,20 @@ + +const Rest = { + Request: class { + constructor(base) { + this.base = base; + } + + get(url) { return fetch(url); } + + post(url, body) { + return fetch( + url, + { + method: 'POST', + body: JSON.stringify(body), + } + ); + } + }, +}; diff --git a/src/z/root.zig b/src/z/root.zig index 26bbffc..b23ebc5 100644 --- a/src/z/root.zig +++ b/src/z/root.zig @@ -25,7 +25,10 @@ pub const html: File = .{ }; pub fn env(comptime components: []const Component) Element { - var children: []const Element = &.{script.load(@embedFile("z.js"))}; + var children: []const Element = &.{ + script.load(@embedFile("z.js")), + script.load(@embedFile("rest.js")), + }; inline for (components) |c| { const child: []const Element = &.{c.toElement()}; -- cgit v1.2.3-70-g09d2