From 687880f27e3da2e36d03c2721ae14a57bf40f8b8 Mon Sep 17 00:00:00 2001 From: Emil Lerch Date: Mon, 6 Sep 2021 15:48:10 -0700 Subject: [PATCH] free requests in demo --- src/aws.zig | 1 + src/main.zig | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/aws.zig b/src/aws.zig index 5f4bcbb..7b987ba 100644 --- a/src/aws.zig +++ b/src/aws.zig @@ -321,6 +321,7 @@ pub fn Request(comptime action: anytype) type { }; } +/// Get request ID from headers. Caller responsible for freeing memory fn requestIdFromHeaders(request: awshttp.HttpRequest, response: awshttp.HttpResult, options: Options) ![]u8 { var request_id: []u8 = undefined; var found = false; diff --git a/src/main.zig b/src/main.zig index fa00892..0081691 100644 --- a/src/main.zig +++ b/src/main.zig @@ -150,10 +150,12 @@ pub fn main() anyerror!void { tags.appendAssumeCapacity(.{ .key = "Foo", .value = "Bar" }); const req = services.lambda.tag_resource.Request{ .resource = arn, .tags = tags.items }; const addtag = try aws.Request(services.lambda.tag_resource).call(req, options); + defer addtag.deinit(); // const addtag = try client.call(services.lambda.tag_resource.Request{ .resource = arn, .tags = &.{.{ .key = "Foo", .value = "Bar" }} }, options); std.log.info("add tag request id: {s}", .{addtag.response_metadata.request_id}); var keys = [_][]const u8{"Foo"}; // Would love to have a way to express this without burning a var here const deletetag = try aws.Request(services.lambda.untag_resource).call(.{ .tag_keys = keys[0..], .resource = arn }, options); + defer deletetag.deinit(); std.log.info("delete tag request id: {s}", .{deletetag.response_metadata.request_id}); } else { std.log.err("no functions to work with", .{});