bring sample up to date for zig 0.13/behave like a lambda
All checks were successful
Generic zig build / build (push) Successful in 59s
All checks were successful
Generic zig build / build (push) Successful in 59s
This commit is contained in:
parent
d87f781328
commit
9a4505e3b7
|
@ -26,6 +26,12 @@ pub fn build(b: *std.Build) !void {
|
|||
|
||||
try @import("lambda-zig").lambdaBuildOptions(b, exe);
|
||||
|
||||
const aws_lambda_dep = b.dependency("lambda-zig", .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
const aws_lambda_module = aws_lambda_dep.module("lambda_runtime");
|
||||
exe.root_module.addImport("aws_lambda_runtime", aws_lambda_module);
|
||||
// This declares intent for the executable to be installed into the
|
||||
// standard location when the user invokes the "install" step (the default
|
||||
// step when running `zig build`).
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
.version = "0.1.0",
|
||||
.dependencies = .{
|
||||
.@"lambda-zig" = .{
|
||||
.url = "https://git.lerch.org/lobo/lambda-zig/archive/ef5b793882c60ff3d9f3e088fc47758e8ec5a2bc.tar.gz",
|
||||
.hash = "122053d827cde4634ab521ee87cc1195abbbdbd9b5ccc66e557764a151f88c138d02",
|
||||
.url = "https://git.lerch.org/lobo/lambda-zig/archive/91149957b58fab30407ffd97abbd3073ad92b39c.tar.gz",
|
||||
.hash = "1220e05a0f97c8a7bcdf426a2228b210937b0105125af179dfbf0243ede75b7da1b2",
|
||||
},
|
||||
},
|
||||
.paths = .{
|
||||
|
|
25
src/main.zig
25
src/main.zig
|
@ -1,24 +1,11 @@
|
|||
const std = @import("std");
|
||||
const lambda = @import("aws_lambda_runtime");
|
||||
|
||||
pub fn main() !void {
|
||||
// Prints to stderr (it's a shortcut based on `std.io.getStdErr()`)
|
||||
std.debug.print("All your {s} are belong to us.\n", .{"codebase"});
|
||||
|
||||
// stdout is for the actual output of your application, for example if you
|
||||
// are implementing gzip, then only the compressed bytes should be sent to
|
||||
// stdout, not any debugging messages.
|
||||
const stdout_file = std.io.getStdOut().writer();
|
||||
var bw = std.io.bufferedWriter(stdout_file);
|
||||
const stdout = bw.writer();
|
||||
|
||||
try stdout.print("Run `zig build test` to run the tests.\n", .{});
|
||||
|
||||
try bw.flush(); // don't forget to flush!
|
||||
pub fn main() anyerror!void {
|
||||
try lambda.run(null, handler);
|
||||
}
|
||||
|
||||
test "simple test" {
|
||||
var list = std.ArrayList(i32).init(std.testing.allocator);
|
||||
defer list.deinit(); // try commenting this out and see if zig detects the memory leak!
|
||||
try list.append(42);
|
||||
try std.testing.expectEqual(@as(i32, 42), list.pop());
|
||||
fn handler(allocator: std.mem.Allocator, event_data: []const u8) ![]const u8 {
|
||||
_ = allocator;
|
||||
return event_data;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user