make config more readable
This commit is contained in:
parent
5614225050
commit
e0decf9df9
1 changed files with 10 additions and 10 deletions
|
|
@ -13,16 +13,16 @@ pub const Config = struct {
|
|||
defer env.deinit();
|
||||
return Config{
|
||||
.listen_host = env.get("WTTR_LISTEN_HOST") orelse try allocator.dupe(u8, "0.0.0.0"),
|
||||
.listen_port = blk: {
|
||||
const port_str = env.get("WTTR_LISTEN_PORT") orelse break :blk 8002;
|
||||
break :blk std.fmt.parseInt(u16, port_str, 10) catch 8002;
|
||||
},
|
||||
.cache_size = blk: {
|
||||
const size_str = env.get("WTTR_CACHE_SIZE") orelse break :blk 10_000;
|
||||
break :blk std.fmt.parseInt(usize, size_str, 10) catch 10_000;
|
||||
},
|
||||
.cache_dir = if (env.get("WTTR_CACHE_DIR")) |v| try allocator.dupe(u8, v) else try allocator.dupe(u8, "/tmp/wttr-cache"),
|
||||
.geolite_path = if (env.get("WTTR_GEOLITE_PATH")) |v| try allocator.dupe(u8, v) else try allocator.dupe(u8, "./GeoLite2-City.mmdb"),
|
||||
.listen_port = if (env.get("WTTR_LISTEN_PORT")) |p|
|
||||
try std.fmt.parseInt(u16, p, 10)
|
||||
else
|
||||
8002,
|
||||
.cache_size = if (env.get("WTTR_CACHE_SIZE")) |s|
|
||||
try std.fmt.parseInt(usize, s, 10)
|
||||
else
|
||||
10_000,
|
||||
.cache_dir = try allocator.dupe(u8, env.get("WTTR_CACHE_DIR") orelse "/tmp/wttr-cache"),
|
||||
.geolite_path = try allocator.dupe(u8, env.get("WTTR_GEOLITE_PATH") orelse "./GeoLite2-City.mmdb"),
|
||||
.geocache_file = if (env.get("WTTR_GEOCACHE_FILE")) |v| try allocator.dupe(u8, v) else null,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue