be clear on which allocator this is
This commit is contained in:
parent
8b51be05af
commit
50f8889e6e
1 changed files with 10 additions and 10 deletions
|
|
@ -87,7 +87,6 @@ fn handleWeatherInternal(
|
|||
res: *httpz.Response,
|
||||
location_query: []const u8,
|
||||
) !void {
|
||||
const allocator = req.arena;
|
||||
|
||||
// Resolve location
|
||||
const location = if (location_query.len == 0)
|
||||
|
|
@ -107,9 +106,10 @@ fn handleWeatherInternal(
|
|||
},
|
||||
}
|
||||
};
|
||||
const req_alloc = req.arena;
|
||||
|
||||
// Fetch weather using coordinates
|
||||
const weather = opts.provider.fetch(allocator, location.coords) catch |err| {
|
||||
const weather = opts.provider.fetch(req_alloc, location.coords) catch |err| {
|
||||
switch (err) {
|
||||
error.LocationNotFound => {
|
||||
res.status = 404;
|
||||
|
|
@ -126,10 +126,10 @@ fn handleWeatherInternal(
|
|||
defer weather.deinit();
|
||||
|
||||
const query_string = req.url.query;
|
||||
const params = try QueryParams.parse(allocator, query_string);
|
||||
const params = try QueryParams.parse(req_alloc, query_string);
|
||||
defer {
|
||||
if (params.format) |f| allocator.free(f);
|
||||
if (params.lang) |l| allocator.free(l);
|
||||
if (params.format) |f| req_alloc.free(f);
|
||||
if (params.lang) |l| req_alloc.free(l);
|
||||
}
|
||||
|
||||
// Determine if imperial units should be used
|
||||
|
|
@ -155,15 +155,15 @@ fn handleWeatherInternal(
|
|||
const output = if (params.format) |fmt| blk: {
|
||||
if (std.mem.eql(u8, fmt, "j1")) {
|
||||
res.content_type = .JSON;
|
||||
break :blk try json.render(allocator, weather);
|
||||
break :blk try json.render(req_alloc, weather);
|
||||
} else if (std.mem.eql(u8, fmt, "v2")) {
|
||||
break :blk try v2.render(allocator, weather, use_imperial);
|
||||
break :blk try v2.render(req_alloc, weather, use_imperial);
|
||||
} else if (std.mem.startsWith(u8, fmt, "%")) {
|
||||
break :blk try custom.render(allocator, weather, fmt, use_imperial);
|
||||
break :blk try custom.render(req_alloc, weather, fmt, use_imperial);
|
||||
} else {
|
||||
break :blk try line.render(allocator, weather, fmt, use_imperial);
|
||||
break :blk try line.render(req_alloc, weather, fmt, use_imperial);
|
||||
}
|
||||
} else try ansi.render(allocator, weather, .{ .use_imperial = use_imperial });
|
||||
} else try ansi.render(req_alloc, weather, .{ .use_imperial = use_imperial });
|
||||
|
||||
if (res.content_type != .JSON) {
|
||||
res.content_type = .TEXT;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue