mirror of
https://github.com/jetzig-framework/jetzig.git
synced 2025-05-14 22:16:08 +00:00
Change in how the std.http.Server works, do() -> send(), init doesn't take an allocator anymore
This commit is contained in:
parent
7e529e2c55
commit
454208d6b5
@ -30,7 +30,7 @@ pub fn init(
|
|||||||
routes: []jetzig.views.Route,
|
routes: []jetzig.views.Route,
|
||||||
templates: []jetzig.TemplateFn,
|
templates: []jetzig.TemplateFn,
|
||||||
) Self {
|
) Self {
|
||||||
const server = std.http.Server.init(allocator, .{ .reuse_address = true });
|
const server = std.http.Server.init( .{ .reuse_address = true });
|
||||||
|
|
||||||
return .{
|
return .{
|
||||||
.server = server,
|
.server = server,
|
||||||
@ -106,7 +106,7 @@ fn processNextRequest(self: *Self, response: *std.http.Server.Response) !void {
|
|||||||
inline else => |status_code| @field(std.http.Status, @tagName(status_code)),
|
inline else => |status_code| @field(std.http.Status, @tagName(status_code)),
|
||||||
};
|
};
|
||||||
|
|
||||||
try response.do();
|
try response.send();
|
||||||
try response.writeAll(result.value.content);
|
try response.writeAll(result.value.content);
|
||||||
|
|
||||||
try response.finish();
|
try response.finish();
|
||||||
@ -307,7 +307,7 @@ fn matchStaticResource(self: *Self, request: *jetzig.http.Request) !?StaticResou
|
|||||||
if (request.path.len < 2) return null;
|
if (request.path.len < 2) return null;
|
||||||
if (request.method != .GET) return null;
|
if (request.method != .GET) return null;
|
||||||
|
|
||||||
var iterable_dir = std.fs.cwd().openIterableDir("public", .{}) catch |err| {
|
var iterable_dir = std.fs.cwd().openDir("public", .{.iterate = true}) catch |err| {
|
||||||
switch (err) {
|
switch (err) {
|
||||||
error.FileNotFound => return null,
|
error.FileNotFound => return null,
|
||||||
else => return err,
|
else => return err,
|
||||||
@ -319,7 +319,7 @@ fn matchStaticResource(self: *Self, request: *jetzig.http.Request) !?StaticResou
|
|||||||
|
|
||||||
if (std.mem.eql(u8, file.path, request.path[1..])) {
|
if (std.mem.eql(u8, file.path, request.path[1..])) {
|
||||||
return .{
|
return .{
|
||||||
.content = try iterable_dir.dir.readFileAlloc(
|
.content = try iterable_dir.readFileAlloc(
|
||||||
request.allocator,
|
request.allocator,
|
||||||
file.path,
|
file.path,
|
||||||
jetzig.config.max_bytes_static_content,
|
jetzig.config.max_bytes_static_content,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user