Compare commits
No commits in common. "5b2a4936a24b70a4b89a6277a8bd75068bba4cd4" and "cd9bf618f193bc96829c6edc90886ca9bb084fe0" have entirely different histories.
5b2a4936a2
...
cd9bf618f1
|
@ -1,7 +1,7 @@
|
||||||
lambda-zig: A Custom Runtime for AWS Lambda
|
lambda-zig: A Custom Runtime for AWS Lambda
|
||||||
===========================================
|
===========================================
|
||||||
|
|
||||||
This is a sample custom runtime built in zig (0.12). Simple projects will execute
|
This is a sample custom runtime built in zig (0.11). Simple projects will execute
|
||||||
in <1ms, with a cold start init time of approximately 11ms.
|
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:
|
Some custom build steps have been added to build.zig, which will only currently appear if compiling from a linux operating system:
|
||||||
|
|
|
@ -165,17 +165,17 @@ const Event = struct {
|
||||||
.{ prefix, lambda_runtime_uri, postfix, self.request_id },
|
.{ prefix, lambda_runtime_uri, postfix, self.request_id },
|
||||||
);
|
);
|
||||||
defer self.allocator.free(response_url);
|
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 };
|
var cl = std.http.Client{ .allocator = self.allocator };
|
||||||
defer cl.deinit();
|
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(.{
|
const res = try cl.fetch(.{
|
||||||
.method = .POST,
|
.method = .POST,
|
||||||
.payload = event_response,
|
.payload = response_content,
|
||||||
.location = .{ .url = response_url },
|
.location = .{ .url = response_url },
|
||||||
});
|
});
|
||||||
if (res.status != .ok) return error.UnexpectedStatusFromPostResponse;
|
if (res.status != .ok) return error.UnexpectedStatusFromPostResponse;
|
||||||
|
@ -420,7 +420,7 @@ test "basic request" {
|
||||||
|
|
||||||
// This is what's actually coming back. Is this right?
|
// This is what's actually coming back. Is this right?
|
||||||
const expected_response =
|
const expected_response =
|
||||||
\\{"foo": "bar", "baz": "qux"}
|
\\{ "content": "{"foo": "bar", "baz": "qux"}" }
|
||||||
;
|
;
|
||||||
const lambda_response = try lambda_request(allocator, request, 1);
|
const lambda_response = try lambda_request(allocator, request, 1);
|
||||||
defer deinit();
|
defer deinit();
|
||||||
|
@ -437,7 +437,7 @@ test "several requests do not fail" {
|
||||||
|
|
||||||
// This is what's actually coming back. Is this right?
|
// This is what's actually coming back. Is this right?
|
||||||
const expected_response =
|
const expected_response =
|
||||||
\\{"foo": "bar", "baz": "qux"}
|
\\{ "content": "{"foo": "bar", "baz": "qux"}" }
|
||||||
;
|
;
|
||||||
const lambda_response = try lambda_request(allocator, request, 5);
|
const lambda_response = try lambda_request(allocator, request, 5);
|
||||||
defer deinit();
|
defer deinit();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user