diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2025-11-15 11:54:00 +0100 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2025-11-15 11:56:24 +0100 |
| commit | e8ff326f0e5bd61fb0a8c22c48f296fcf0249830 (patch) | |
| tree | 19d8c026f8460ec577f446a7d61e68c38acddde0 /src/routes/fallback.zig | |
| parent | 007bc3fe0615f38cb31d5116759ed3500f6fd3e6 (diff) | |
backend implement auth-service
Diffstat (limited to 'src/routes/fallback.zig')
| -rw-r--r-- | src/routes/fallback.zig | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/src/routes/fallback.zig b/src/routes/fallback.zig deleted file mode 100644 index 25e1927..0000000 --- a/src/routes/fallback.zig +++ /dev/null @@ -1,37 +0,0 @@ -const std = @import("std"); -const mime = @import("../mime.zig"); -const Context = @import("context.zig"); - -const log = std.log.scoped(.fallback); - -pub const needs_auth = false; -pub const method = .GET; - -pub fn handler(ctx: *Context) anyerror![]const u8 { - var static = try std.fs.cwd().openDir("static", .{}); - defer static.close(); - - if (static.openFile(ctx.request.head.target[1..], .{})) |file| { - defer file.close(); - const content = file.readToEndAlloc(ctx.allocator, std.math.maxInt(usize)); - const mime_type = mime.get_type(ctx.request.head.target); - ctx.response.headers.content_type = mime_type; - return content; - } else |_| { - var subdir = if (ctx.request.head.target.len == 1) static - else (static.openDir(ctx.request.head.target[1..], .{}) catch { - return error.NotFound; - }); - defer if (ctx.request.head.target.len > 1) subdir.close(); - - if (subdir.openFile("index.html", .{})) |file| { - defer file.close(); - const content = file.readToEndAlloc(ctx.allocator, std.math.maxInt(usize)); - ctx.response.headers.content_type = "text/html"; - return content; - } else |_| { - log.warn("File '{s}' Not Found", .{ ctx.request.head.target }); - return error.NotFound; - } - } -} |