From 4006b43679761e138a6e94f5b23c6b184da6f1e5 Mon Sep 17 00:00:00 2001 From: Emil Lerch Date: Wed, 25 Oct 2023 00:16:38 -0700 Subject: [PATCH] update to latest universal --- build.zig | 5 +++-- build.zig.zon | 4 ++-- src/main.zig | 10 ++++------ 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/build.zig b/build.zig index 8bcd3b1..ff6f368 100644 --- a/build.zig +++ b/build.zig @@ -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); diff --git a/build.zig.zon b/build.zig.zon index 012d19a..1335f02 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -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", diff --git a/src/main.zig b/src/main.zig index c3aa7ff..020ea38 100644 --- a/src/main.zig +++ b/src/main.zig @@ -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; }