diff options
| author | Robby Zambito <contact@robbyzambito.me> | 2026-01-12 19:18:45 -0500 |
|---|---|---|
| committer | Robby Zambito <contact@robbyzambito.me> | 2026-01-12 22:21:48 -0500 |
| commit | 1ee0f9263cd8e2984237ff34ae4625e8aaf2680c (patch) | |
| tree | e91d4fa1f6c890f02cf9fbaebe3912e3774777d2 /src/subcommand/serve.zig | |
| parent | c5ad98adc6ebea6627fc08c2c16324610a8a97e0 (diff) | |
add max bytes setting
Diffstat (limited to 'src/subcommand/serve.zig')
| -rw-r--r-- | src/subcommand/serve.zig | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/subcommand/serve.zig b/src/subcommand/serve.zig index e6bb648..9cb35bb 100644 --- a/src/subcommand/serve.zig +++ b/src/subcommand/serve.zig @@ -30,7 +30,7 @@ pub fn main(alloc: Allocator, outer_io: Io, args: []const [:0]const u8) !void { .server_id = Server.default_id, .server_name = Server.default_name, .version = "zits-master", - .max_payload = 1048576, + .max_payload = 1 * 1024 * 1024, .headers = true, }; @@ -54,6 +54,18 @@ pub fn main(alloc: Allocator, outer_io: Io, args: []const [:0]const u8) !void { return; } }, + .max_bytes => { + i += 1; + if (args.len > i) { + server_config.max_payload = std.fmt.parseUnsigned(usize, args[i], 10) catch { + std.log.err("Could not parse max bytes: {s}", .{args[i]}); + return; + }; + } else { + std.log.err("Must specify max bytes with {s}", .{args[i - 1]}); + return; + } + }, } } } @@ -90,16 +102,23 @@ pub fn main(alloc: Allocator, outer_io: Io, args: []const [:0]const u8) !void { std.log.info("Goodbye", .{}); } -const help = "serve help\n"; +const help = + \\--port/-p <n> Specify port + \\--help/-h Get help. + \\--max-bytes <n> Specify max message byte size + \\ +; const to_flag: std.StaticStringMap(Flag) = .initComptime(.{ .{ "-p", .port }, .{ "--port", .port }, .{ "-h", .help }, .{ "--help", .help }, + .{ "--max-bytes", .max_bytes }, }); const Flag = enum { port, help, + max_bytes, }; |
