Skip to content

Commit

Permalink
chore: general standardization
Browse files Browse the repository at this point in the history
  • Loading branch information
mookums committed Dec 18, 2024
1 parent 3bb64a8 commit 0bf3cbf
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/http/router.zig
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub fn default_not_found_handler(comptime Server: type, comptime AppState: type)
try ctx.respond(.{
.status = .@"Not Found",
.mime = Mime.TEXT,
.body = "Not found.",
.body = "Not Found",
});
}
}.not_found_handler;
Expand Down
2 changes: 2 additions & 0 deletions src/http/router/fs_dir.zig
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ pub fn FsDir(Server: type, AppState: type) type {
// Resolving the requested file.
const search_path = ctx.captures[0].remaining;
const resolved_file_path = blk: {
// This appears to be leaking BUT the ctx.allocator is an
// arena so it does get cleaned up eventually.
const file_path = std.fs.path.resolve(
ctx.allocator,
&[_][]const u8{ dir_path, search_path },
Expand Down
8 changes: 2 additions & 6 deletions src/http/router/route.zig
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ pub fn Route(comptime Server: type, comptime AppState: type) type {
}

/// Initialize a route for the given path.
pub fn init(_path: []const u8) Self {
return Self{
.path = _path,
};
pub fn init(path: []const u8) Self {
return Self{ .path = path };
}

/// Returns a comma delinated list of allowed Methods for this route. This
Expand Down Expand Up @@ -211,9 +209,7 @@ pub fn Route(comptime Server: type, comptime AppState: type) type {
);

return self
// Set the new path.
.set_path(url_with_match_all)
// Set GET handler.
.get(struct {
fn handler_fn(ctx: *Context) !void {
try FsDir.handler_fn(ctx, dir_path);
Expand Down

0 comments on commit 0bf3cbf

Please sign in to comment.