Compare commits

...

2 Commits

Author SHA1 Message Date
5b2a4936a2
no longer wrap output of event handler data
All checks were successful
Generic zig build / build (push) Successful in 53s
2024-05-05 13:02:15 -07:00
f9e44210c0
update version in readme 2024-05-05 12:47:01 -07:00
2 changed files with 10 additions and 10 deletions

View File

@ -1,7 +1,7 @@
lambda-zig: A Custom Runtime for AWS Lambda
===========================================
This is a sample custom runtime built in zig (0.11). Simple projects will execute
This is a sample custom runtime built in zig (0.12). Simple projects will execute
in <1ms, with a cold start init time of approximately 11ms.
Some custom build steps have been added to build.zig, which will only currently appear if compiling from a linux operating system:

View File

@ -165,17 +165,17 @@ const Event = struct {
.{ prefix, lambda_runtime_uri, postfix, self.request_id },
);
defer self.allocator.free(response_url);
const response_content = try std.fmt.allocPrint(
self.allocator,
"{{ \"content\": \"{s}\" }}",
.{event_response},
);
defer self.allocator.free(response_content);
var cl = std.http.Client{ .allocator = self.allocator };
defer cl.deinit();
// Lambda does different things, depending on the runtime. Go 1.x takes
// any return value but escapes double quotes. Custom runtimes can
// do whatever they want. node I believe wraps as a json object. We're
// going to leave the return value up to the handler, and they can
// use a seperate API for normalization so we're explicit. As a result,
// we can just post event_response completely raw here
const res = try cl.fetch(.{
.method = .POST,
.payload = response_content,
.payload = event_response,
.location = .{ .url = response_url },
});
if (res.status != .ok) return error.UnexpectedStatusFromPostResponse;
@ -420,7 +420,7 @@ test "basic request" {
// This is what's actually coming back. Is this right?
const expected_response =
\\{ "content": "{"foo": "bar", "baz": "qux"}" }
\\{"foo": "bar", "baz": "qux"}
;
const lambda_response = try lambda_request(allocator, request, 1);
defer deinit();
@ -437,7 +437,7 @@ test "several requests do not fail" {
// This is what's actually coming back. Is this right?
const expected_response =
\\{ "content": "{"foo": "bar", "baz": "qux"}" }
\\{"foo": "bar", "baz": "qux"}
;
const lambda_response = try lambda_request(allocator, request, 5);
defer deinit();