mirror of
https://github.com/jetzig-framework/jetzig.git
synced 2025-05-14 22:16:08 +00:00
Document default config values in init project
This commit is contained in:
parent
381c38d85d
commit
cc0a1c5792
@ -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 {
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
Loading…
x
Reference in New Issue
Block a user