update to latest universal
All checks were successful
AWS-Zig Build / build-zig-0.11.0-amd64-host (push) Successful in 1m43s

This commit is contained in:
Emil Lerch 2023-10-25 00:16:38 -07:00
parent bc755fb2c4
commit 4006b43679
Signed by: lobo
GPG Key ID: A7B62D657EF764F8
3 changed files with 9 additions and 10 deletions

View File

@ -1,5 +1,5 @@
const std = @import("std");
const configureUniversalLambdaBuild = @import("universal_lambda_build").configureBuild;
const universal_lambda_build = @import("universal_lambda_build");
// Although this function looks imperative, note that its job is to
// declaratively construct a build graph that will be executed by an external
@ -26,7 +26,7 @@ pub fn build(b: *std.Build) !void {
});
// All modules should be added before this is called
try configureUniversalLambdaBuild(b, exe);
try universal_lambda_build.configureBuild(b, exe);
// This declares intent for the executable to be installed into the
// standard location when the user invokes the "install" step (the default
@ -63,6 +63,7 @@ pub fn build(b: *std.Build) !void {
.target = target,
.optimize = optimize,
});
_ = try universal_lambda_build.addModules(b, unit_tests);
const run_unit_tests = b.addRunArtifact(unit_tests);

View File

@ -4,8 +4,8 @@
.dependencies = .{
.universal_lambda_build = .{
.url = "https://git.lerch.org/lobo/universal-lambda-zig/archive/6c89380fea51686b775a93d9a68150262a20d513.tar.gz",
.hash = "1220173c05fa58d0dceda2e2de99edb1a68b859006747cfcf80d7c908dda95f87db2",
.url = "https://git.lerch.org/lobo/universal-lambda-zig/archive/5376b6a725d406b0b9581eb65505a852730d6a98.tar.gz",
.hash = "1220fb872507639f1d42f11a50f33dbdc0343a888c6592892a38ba210e6e0ae6285c",
},
.flexilib = .{
.url = "https://git.lerch.org/lobo/flexilib/archive/3d3dab9c792651477932e2b61c9f4794ac694dcb.tar.gz",

View File

@ -1,23 +1,21 @@
const std = @import("std");
const universal_lambda = @import("universal_lambda_handler");
const helpers = @import("universal_lambda_helpers"); // not necessary, but these functions provide common access to common things
const interface = @import("universal_lambda_interface");
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 {
fn handler(allocator: std.mem.Allocator, event_data: []const u8, context: interface.Context) ![]const u8 {
// our allocator is an area, so yolo
const target = try helpers.findTarget(allocator, context);
var al = std.ArrayList(u8).init(allocator);
var writer = al.writer();
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| {
for (context.request.headers.list.items) |f| {
try writer.print("\t{s}: {s}\n", .{ f.name, f.value });
}
try writer.print("======================================================================\n", .{});
try writer.print("Event handler target: {s}\n", .{target});
try writer.print("Event handler target: {s}\n", .{context.request.target});
try writer.print("Event data passed to handler: {s}\n", .{event_data});
return al.items;
}