jetzig/demo/src/app/views/background_jobs.zig
Bob Farrell 65edd20092 Allow mailers to modify mail template params
Remove need to add all mail template params to view response data. This
was originally intended functionality but the wrong value was passed to
the `deliver` function, and no `data` argument was given, making it
cumbersome to create new values.
2024-05-05 20:04:57 +01:00

18 lines
571 B
Zig

const std = @import("std");
const jetzig = @import("jetzig");
/// This example demonstrates usage of Jetzig's background jobs.
pub fn index(request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
// Prepare a job using `src/app/jobs/example.zig`.
var job = try request.job("example");
// Add a param `foo` to the job.
try job.params.put("foo", data.string("bar"));
try job.params.put("id", data.integer(std.crypto.random.int(u32)));
// Schedule the job for background processing.
try job.schedule();
return request.render(.ok);
}