Compare commits
2 Commits
05dd8b7e06
...
6c89380fea
Author | SHA1 | Date | |
---|---|---|---|
6c89380fea | |||
983a1a6649 |
|
@ -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
|
// handleRequest function here is the last line of boilerplate and the
|
||||||
// entry to a request
|
// 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
|
// setup
|
||||||
var response_writer = response.body.writer();
|
var response_writer = response.body.writer();
|
||||||
// dispatch to our actual handler
|
// dispatch to our actual handler
|
||||||
try response_writer.writeAll(try client_handler.handler(allocator, request.content, .{ .flexilib = .{
|
try response_writer.writeAll(try client_handler.handler(
|
||||||
.request = request,
|
allocator,
|
||||||
.response = response,
|
response.request.content,
|
||||||
} }));
|
.{
|
||||||
|
.flexilib = response,
|
||||||
|
},
|
||||||
|
));
|
||||||
}
|
}
|
||||||
// Need to figure out how tests would work
|
// Need to figure out how tests would work
|
||||||
test "handle_request" {
|
test "handle_request" {
|
||||||
|
|
|
@ -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
|
// Lambda does not have context, just environment variables. API Gateway
|
||||||
// might be configured to pass in lots of context, but this comes through
|
// might be configured to pass in lots of context, but this comes through
|
||||||
// event data, not context.
|
// event data, not context.
|
||||||
var response = UniversalLambdaResponse.init(allocator.?);
|
var response = UniversalLambdaResponse.init(req_allocator);
|
||||||
response.output_file = std.io.getStdOut();
|
response.output_file = std.io.getStdOut();
|
||||||
const event_response = event_handler(req_allocator, event.event_data, .{ .none = &response }) catch |err| {
|
const event_response = event_handler(req_allocator, event.event_data, .{ .none = &response }) catch |err| {
|
||||||
response.finish() catch unreachable;
|
response.finish() catch unreachable;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user