diff options
Diffstat (limited to 'src/routes/handler-info.zig')
| -rw-r--r-- | src/routes/handler-info.zig | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/routes/handler-info.zig b/src/routes/handler-info.zig index 97eb9bd..5183628 100644 --- a/src/routes/handler-info.zig +++ b/src/routes/handler-info.zig @@ -51,6 +51,9 @@ pub fn handle( storage: *Storage, allocator: std.mem.Allocator, ) !void { + const target = try allocator.dupe(u8, request.head.target); + defer allocator.free(target); + const handler = self.handler_from_method(request.head.method) orelse return request.respond( "{ \"error\": \"Bad Request\" }", .{ .status = .bad_request } @@ -102,7 +105,7 @@ pub fn handle( error.Forbidden => .{ "{ \"error\": \"Forbidden\" }", .forbidden }, error.NotFound => .{ "{ \"error\": \"Not Found\" }", .not_found }, else => blk: { - log.err("handler for '{s}' returned {}", .{request.head.target, err}); + log.err("handler for '{s}' returned {}", .{target, err}); break :blk .{ "{ \"error\": \"Internal Server Error\" }", .internal_server_error }; }, }; @@ -122,7 +125,7 @@ pub fn handle( if (context.response.headers.fingerprint) |auth_token| { var value = std.Io.Writer.Allocating.init(arena.allocator()); - try value.writer.print("fingerprint={s}; Secure; Path=/", .{auth_token}); + try value.writer.print("fingerprint={s}; Path=/", .{auth_token}); try headers.append(allocator, .{ .name = "Set-Cookie", @@ -184,7 +187,7 @@ fn HandlerWrapper(T: type, name: []const u8) type { return @call(.auto, @field(T, name), args); } else if (payload_type == void) { try @call(.auto, @field(T, name), args); - return memora.Stream.from_buffer(""); + return memora.Stream.from_buffer("{}"); } else { var writer = std.Io.Writer.Allocating.init(ctx.allocator); var stringify = std.json.Stringify { .writer = &writer.writer }; |