aboutsummaryrefslogtreecommitdiff
path: root/src/z
diff options
context:
space:
mode:
Diffstat (limited to 'src/z')
-rw-r--r--src/z/rest.js20
-rw-r--r--src/z/root.zig5
2 files changed, 24 insertions, 1 deletions
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()};