Update Jetzig

This commit is contained in:
Samuel Webb 2024-09-13 13:44:38 -04:00
parent fa4c3a6eff
commit b1a21d63df
4 changed files with 47 additions and 4 deletions

2
.gitignore vendored
View file

@ -1,5 +1,5 @@
zig-out/ zig-out/
zig-cache/ .zig-cache/
*.core *.core
static/ static/
.jetzig .jetzig

View file

@ -15,8 +15,8 @@
// Once all dependencies are fetched, `zig build` no longer requires // Once all dependencies are fetched, `zig build` no longer requires
// internet connectivity. // internet connectivity.
.dependencies = .{ .jetzig = .{ .dependencies = .{ .jetzig = .{
.url = "https://github.com/jetzig-framework/jetzig/archive/88abe2243d87b28ad110c5fe9fe90b716a6c6583.tar.gz", .url = "https://github.com/jetzig-framework/jetzig/archive/dda433bb73000614482af10a277d47dc9d89600c.tar.gz",
.hash = "12200d15cef72d4c37a01c930db53c3ffafdc05142462afddeab818701a0291327d1", .hash = "12202ce84b803a8b300c91d98afbc7c326298b55a23bf05cf603182e934b621008ec",
}, .iguanas = .{ }, .iguanas = .{
.url = "https://github.com/jetzig-framework/iguanas/archive/89c2abf29de0bc31054a9a6feac5a6a83bab0459.tar.gz", .url = "https://github.com/jetzig-framework/iguanas/archive/89c2abf29de0bc31054a9a6feac5a6a83bab0459.tar.gz",
.hash = "12202fd319a5ab4e124b00e8ddea474d07c19c4e005d77b6c29fc44860904ea01a5c", .hash = "12202fd319a5ab4e124b00e8ddea474d07c19c4e005d77b6c29fc44860904ea01a5c",

41
src/app/views/music.zig Normal file
View file

@ -0,0 +1,41 @@
const std = @import("std");
const jetzig = @import("jetzig");
pub const static_params = .{
.index = .{
//.{ .params = .{ .foo = "hi", .bar = "bye" } },
//.{ .params = .{ .foo = "hello", .bar = "goodbye" } },
},
//.get = .{
// .{ .id = "1", .params = .{ .foo = "hi", .bar = "bye" } },
// .{ .id = "2", .params = .{ .foo = "hello", .bar = "goodbye" } },
//},
};
pub fn index(request: *jetzig.StaticRequest, data: *jetzig.Data) !jetzig.View {
var root = try data.object();
const params = try request.params();
if (params.get("foo")) |foo| try root.put("foo", foo);
if (params.get("foo") == null) try root.put("foo", data.string("no foo"));
if (params.get("bar")) |bar| try root.put("bar", bar);
if (params.get("bar") == null) try root.put("bar", data.string("no bar"));
return request.render(.ok);
}
//pub fn get(id: []const u8, request: *jetzig.StaticRequest, data: *jetzig.Data) !jetzig.View {
// var root = try data.object();
//
// const params = try request.params();
//
// if (std.mem.eql(u8, id, "1")) {
// try root.put("id", data.string("id is '1'"));
// }
//
// if (params.get("foo")) |foo| try root.put("foo", foo);
// if (params.get("bar")) |bar| try root.put("bar", bar);
//
// return request.render(.created);
//}

View file

@ -0,0 +1,2 @@
<div>{{.foo}}</div>
<div>{{.bar}}</div>