more complete example/update to latest universal lambda
All checks were successful
AWS-Zig Build / build-zig-0.11.0-amd64-host (push) Successful in 1m9s
All checks were successful
AWS-Zig Build / build-zig-0.11.0-amd64-host (push) Successful in 1m9s
This commit is contained in:
parent
5351480102
commit
bc755fb2c4
|
@ -4,12 +4,12 @@
|
|||
|
||||
.dependencies = .{
|
||||
.universal_lambda_build = .{
|
||||
.url = "https://git.lerch.org/lobo/universal-lambda-zig/archive/70b0fda03b9c54a6eda8d61cb8ab8b9d9f29b2ef.tar.gz",
|
||||
.hash = "122004f2a4ad253be9b8d7989ca6508af1483d8a593ca7fee93627444b2b37d170d2",
|
||||
.url = "https://git.lerch.org/lobo/universal-lambda-zig/archive/6c89380fea51686b775a93d9a68150262a20d513.tar.gz",
|
||||
.hash = "1220173c05fa58d0dceda2e2de99edb1a68b859006747cfcf80d7c908dda95f87db2",
|
||||
},
|
||||
.flexilib = .{
|
||||
.url = "https://git.lerch.org/lobo/flexilib/archive/c44ad2ba84df735421bef23a2ad612968fb50f06.tar.gz",
|
||||
.hash = "122051fdfeefdd75653d3dd678c8aa297150c2893f5fad0728e0d953481383690dbc",
|
||||
.url = "https://git.lerch.org/lobo/flexilib/archive/3d3dab9c792651477932e2b61c9f4794ac694dcb.tar.gz",
|
||||
.hash = "1220fd7a614fe3c9f6006b630bba528e2ec9dca9c66f5ff10f7e471ad2bdd41b6c89",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
19
src/main.zig
19
src/main.zig
|
@ -1,8 +1,9 @@
|
|||
const std = @import("std");
|
||||
const universal_lambda = @import("universal_lambda_handler");
|
||||
const helpers = @import("helpers.zig"); // not necessary, but these functions provide common access to common things
|
||||
pub fn main() !void {
|
||||
try universal_lambda.run(null, handler);
|
||||
const helpers = @import("universal_lambda_helpers"); // not necessary, but these functions provide common access to common things
|
||||
|
||||
pub fn main() !u8 {
|
||||
return try universal_lambda.run(null, handler);
|
||||
}
|
||||
|
||||
pub fn handler(allocator: std.mem.Allocator, event_data: []const u8, context: universal_lambda.Context) ![]const u8 {
|
||||
|
@ -10,11 +11,13 @@ pub fn handler(allocator: std.mem.Allocator, event_data: []const u8, context: un
|
|||
const target = try helpers.findTarget(allocator, context);
|
||||
var al = std.ArrayList(u8).init(allocator);
|
||||
var writer = al.writer();
|
||||
var args = try std.process.argsWithAllocator(allocator);
|
||||
while (args.next()) |arg| {
|
||||
try writer.print("\tcalled with arg: {s}\n", .{arg});
|
||||
var headers = try helpers.allHeaders(allocator, context);
|
||||
try writer.print("Header data passed to handler (if console, this is args+env vars)\n", .{});
|
||||
for (headers.http_headers.list.items) |f| {
|
||||
try writer.print("\t{s}: {s}\n", .{ f.name, f.value });
|
||||
}
|
||||
try writer.print("(target: {s}) Event data, from you, to me, to you: {s}\n", .{ target, event_data });
|
||||
try writer.print("Value for header 'Foo' is: {s}\n", .{try helpers.getFirstHeaderValue(allocator, context, "foo") orelse "undefined"});
|
||||
try writer.print("======================================================================\n", .{});
|
||||
try writer.print("Event handler target: {s}\n", .{target});
|
||||
try writer.print("Event data passed to handler: {s}\n", .{event_data});
|
||||
return al.items;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user