location_query is never null

This commit is contained in:
Emil Lerch 2025-12-18 18:01:20 -08:00
parent a172a9a325
commit ac6ddf829d
Signed by: lobo
GPG key ID: A7B62D657EF764F8

View file

@ -87,7 +87,7 @@ fn handleWeatherInternal(
opts: *HandleWeatherOptions, opts: *HandleWeatherOptions,
req: *httpz.Request, req: *httpz.Request,
res: *httpz.Response, res: *httpz.Response,
location_query: ?[]const u8, location_query: []const u8,
) !void { ) !void {
const allocator = req.arena; const allocator = req.arena;
@ -100,11 +100,10 @@ fn handleWeatherInternal(
} }
// Resolve location // Resolve location
const loc_str = location_query orelse ""; const location = if (location_query.len == 0)
const location = if (loc_str.len == 0)
Location{ .name = "London", .coords = .{ .latitude = 51.5074, .longitude = -0.1278 } } Location{ .name = "London", .coords = .{ .latitude = 51.5074, .longitude = -0.1278 } }
else else
opts.resolver.resolve(loc_str) catch |err| { opts.resolver.resolve(location_query) catch |err| {
switch (err) { switch (err) {
error.LocationNotFound => { error.LocationNotFound => {
res.status = 404; res.status = 404;