Compare commits

..

2 Commits

Author SHA1 Message Date
6c89380fea
address null reference on AWS
All checks were successful
AWS-Zig Build / build-zig-0.11.0-amd64-host (push) Successful in 1m32s
2023-10-23 14:05:44 -07:00
983a1a6649
fix flexilib interface 2023-10-23 13:55:36 -07:00
2 changed files with 9 additions and 6 deletions

View File

@ -59,14 +59,17 @@ export fn handle_request(request: *interface.Request) callconv(.C) ?*interface.R
//
// handleRequest function here is the last line of boilerplate and the
// entry to a request
fn handleRequest(allocator: std.mem.Allocator, request: interface.ZigRequest, response: interface.ZigResponse) !void {
fn handleRequest(allocator: std.mem.Allocator, response: *interface.ZigResponse) !void {
// setup
var response_writer = response.body.writer();
// dispatch to our actual handler
try response_writer.writeAll(try client_handler.handler(allocator, request.content, .{ .flexilib = .{
.request = request,
.response = response,
} }));
try response_writer.writeAll(try client_handler.handler(
allocator,
response.request.content,
.{
.flexilib = response,
},
));
}
// Need to figure out how tests would work
test "handle_request" {

View File

@ -71,7 +71,7 @@ pub fn run(allocator: ?std.mem.Allocator, event_handler: HandlerFn) !u8 { // TOD
// Lambda does not have context, just environment variables. API Gateway
// might be configured to pass in lots of context, but this comes through
// event data, not context.
var response = UniversalLambdaResponse.init(allocator.?);
var response = UniversalLambdaResponse.init(req_allocator);
response.output_file = std.io.getStdOut();
const event_response = event_handler(req_allocator, event.event_data, .{ .none = &response }) catch |err| {
response.finish() catch unreachable;