diff --git a/demo/src/main.zig b/demo/src/main.zig index bfd2fec..268d2eb 100644 --- a/demo/src/main.zig +++ b/demo/src/main.zig @@ -3,19 +3,33 @@ const std = @import("std"); pub const jetzig = @import("jetzig"); pub const routes = @import("routes").routes; -// Override default settings in jetzig.config here: +// Override default settings in `jetzig.config` here: pub const jetzig_options = struct { + /// Middleware chain. Add any custom middleware here, or use middleware provided in + /// `jetzig.middleware` (e.g. `jetzig.middleware.HtmxMiddleware`). pub const middleware: []const type = &.{ // htmx middleware skips layouts when `HX-Target` header is present and issues // `HX-Redirect` instead of a regular HTTP redirect when `request.redirect` is called. jetzig.middleware.HtmxMiddleware, + // Demo middleware included with new projects. Remove once you are familiar with Jetzig's + // middleware system. @import("app/middleware/DemoMiddleware.zig"), }; - pub const max_bytes_request_body: usize = std.math.pow(usize, 2, 16); - pub const max_bytes_static_content: usize = std.math.pow(usize, 2, 16); - pub const http_buffer_size: usize = std.math.pow(usize, 2, 16); - pub const public_content_path = "public"; + // Maximum bytes to allow in request body. + // pub const max_bytes_request_body: usize = std.math.pow(usize, 2, 16); + + // Maximum filesize for `public/` content. + // pub const max_bytes_public_content: usize = std.math.pow(usize, 2, 20); + + // Maximum filesize for `static/` content (applies only to apps using `jetzig.http.StaticRequest`). + // pub const max_bytes_static_content: usize = std.math.pow(usize, 2, 18); + + // Path relative to cwd() to serve public content from. Symlinks are not followed. + // pub const public_content_path = "public"; + + // HTTP buffer. Must be large enough to store all headers. This should typically not be modified. + // pub const http_buffer_size: usize = std.math.pow(usize, 2, 16); }; pub fn main() !void { diff --git a/src/jetzig.zig b/src/jetzig.zig index 39be497..3657618 100644 --- a/src/jetzig.zig +++ b/src/jetzig.zig @@ -49,7 +49,10 @@ pub const config = struct { pub const max_bytes_request_body: usize = std.math.pow(usize, 2, 16); /// Maximum filesize for `public/` content. - pub const max_bytes_static_content: usize = std.math.pow(usize, 2, 16); + pub const max_bytes_public_content: usize = std.math.pow(usize, 2, 20); + + /// Maximum filesize for `static/` content (applies only to apps using `jetzig.http.StaticRequest`). + pub const max_bytes_static_content: usize = std.math.pow(usize, 2, 18); /// Path relative to cwd() to serve public content from. Symlinks are not followed. pub const public_content_path = "public"; diff --git a/src/jetzig/http/Server.zig b/src/jetzig/http/Server.zig index fe95207..dd8b60e 100644 --- a/src/jetzig/http/Server.zig +++ b/src/jetzig/http/Server.zig @@ -378,7 +378,7 @@ fn matchPublicContent(self: *Self, request: *jetzig.http.Request) !?StaticResour const content = try iterable_dir.readFileAlloc( request.allocator, file.path, - jetzig.config.get(usize, "max_bytes_static_content"), + jetzig.config.get(usize, "max_bytes_public_content"), ); const extension = std.fs.path.extension(file.path); const mime_type = if (self.mime_map.get(extension)) |mime| mime else "application/octet-stream";