diff --git a/build.zig.zon b/build.zig.zon index c506570..84b2c3d 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -23,8 +23,8 @@ .hash = "1220d4f1c2472769b0d689ea878f41f0a66cb07f28569a138aea2c0a648a5c90dd4e", }, .httpz = .{ - .url = "https://github.com/karlseguin/http.zig/archive/f3ad561fd23262c3f9b8081ff7bb8a5ded0e74bd.tar.gz", - .hash = "1220ea0d5860657d59cf1ca0fe0e553bfabc7d9cd467005488155baffb1ddf65ecf2", + .url = "https://github.com/karlseguin/http.zig/archive/12764925eb6a7929004c1be9032b04f97f4e43e2.tar.gz", + .hash = "1220ffb589c6cd1a040bfd4446c74c38b5e873ba82e737cb33c98711c95787b92c81", }, }, diff --git a/src/jetzig/colors.zig b/src/jetzig/colors.zig index 4a4f14d..2f7d6a8 100644 --- a/src/jetzig/colors.zig +++ b/src/jetzig/colors.zig @@ -31,27 +31,52 @@ pub const codes = .{ /// Map color codes generated by `std.io.tty.Config.setColor` back to `std.io.tty.Color`. Used by /// `jetzig.loggers.LogQueue.writeWindows` to parse escape codes so they can be passed to /// `std.io.tty.Config.setColor` (using Windows API to set console color mode). -pub const codes_map = std.StaticStringMap(std.io.tty.Color).initComptime(.{ - .{ "30", .black }, - .{ "31", .red }, - .{ "32", .green }, - .{ "33", .yellow }, - .{ "34", .blue }, - .{ "35", .magenta }, - .{ "36", .cyan }, - .{ "37", .white }, - .{ "90", .bright_black }, - .{ "91", .bright_red }, - .{ "92", .bright_green }, - .{ "93", .bright_yellow }, - .{ "94", .bright_blue }, - .{ "95", .bright_magenta }, - .{ "96", .bright_cyan }, - .{ "97", .bright_white }, - .{ "1", .bold }, - .{ "2", .dim }, - .{ "0", .reset }, -}); +const codes_map = if (@hasDecl(std, "ComptimeStringMap")) + std.ComptimeStringMap(std.io.tty.Color, .{ + .{ "30", .black }, + .{ "31", .red }, + .{ "32", .green }, + .{ "33", .yellow }, + .{ "34", .blue }, + .{ "35", .magenta }, + .{ "36", .cyan }, + .{ "37", .white }, + .{ "90", .bright_black }, + .{ "91", .bright_red }, + .{ "92", .bright_green }, + .{ "93", .bright_yellow }, + .{ "94", .bright_blue }, + .{ "95", .bright_magenta }, + .{ "96", .bright_cyan }, + .{ "97", .bright_white }, + .{ "1", .bold }, + .{ "2", .dim }, + .{ "0", .reset }, + }) +else if (@hasDecl(std, "StaticStringMap")) + std.StaticStringMap(std.io.tty.Color).initComptime(.{ + .{ "30", .black }, + .{ "31", .red }, + .{ "32", .green }, + .{ "33", .yellow }, + .{ "34", .blue }, + .{ "35", .magenta }, + .{ "36", .cyan }, + .{ "37", .white }, + .{ "90", .bright_black }, + .{ "91", .bright_red }, + .{ "92", .bright_green }, + .{ "93", .bright_yellow }, + .{ "94", .bright_blue }, + .{ "95", .bright_magenta }, + .{ "96", .bright_cyan }, + .{ "97", .bright_white }, + .{ "1", .bold }, + .{ "2", .dim }, + .{ "0", .reset }, + }) +else + unreachable; /// Colorize a log message. Note that we force `.escape_codes` when we are a TTY even on Windows. /// `jetzig.loggers.LogQueue` parses the ANSI codes and uses `std.io.tty.Config.setColor` to diff --git a/src/jetzig/util.zig b/src/jetzig/util.zig index be93d39..6b05d9f 100644 --- a/src/jetzig/util.zig +++ b/src/jetzig/util.zig @@ -70,7 +70,3 @@ pub fn generateSecret(allocator: std.mem.Allocator, comptime len: u10) ![]const pub fn duration(start_time: i128) i64 { return @intCast(std.time.nanoTimestamp() - start_time); } - -pub inline fn strip(string: []const u8) []const u8 { - return std.mem.trim(u8, string, &std.ascii.whitespace); -}