mirror of
https://github.com/jetzig-framework/jetzig.git
synced 2025-05-14 22:16:08 +00:00

In `main()`: ```zig app.route(.GET, "/custom/:id/foo/bar", @import("app/views/custom/foo.zig"), .bar); ``` Routes `GET` request with path (e.g.) `/custom/1234/foo/bar` to `bar()` defined in `src/app/views/custom/foo.zig`. Routes with an `:id` segment expect a function with three parameters, routes without an `:id` segment expect a function with two parameters (i.e. the same as `get` vs `index`).
8 lines
232 B
Zig
8 lines
232 B
Zig
const jetzig = @import("jetzig");
|
|
|
|
pub fn bar(id: []const u8, request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
|
|
var root = try data.object();
|
|
try root.put("id", data.string(id));
|
|
return request.render(.ok);
|
|
}
|